My website consists mainly of pages that are loaded into an iframe on the homepage.
When the pages are loaded they check if they have been opened outside the iframe and if they are the homepage is opened.
Now I want to open this specific page when the homepage is opened.
How do I send the information that the "browser came from" test.html? And then set the source of the iframe to be test.html?
The syntax
top.document.referrer
will let you access the parent of the iFrame;
document.getElementById('myIframeId').src = myUrl + 'test.html';
will set the iFrame source.
Pass the URL of the page to be framed in the query string of the URL to the page containing the frame.
Related
Suppose I have a web page let's say rooms.html and the URL of that page is "http://localhost:8000/hotel/rooms/". In that HTML page there is a link to add_room.html page, when I click on that link, I get redirected to add_room.html whose URL is "http://localhost:8000/hotel/add_room/". I want to know what should I keep the UPL of this page. Should it be "http://localhost:8000/hotel/add_room/" or "http://localhost:8000/hotel/rooms/add_room/". So bascically my question is that when navigating to a different web page from a webpage should the URL of the new webpage contain the endpoint of the previous web page?
how to retrieve the url from an iframe, when a user goes or clicks to next page inside iframe.
i mean for website which allows x-frame-options.
(src attribute is on external server page)
Eg:<iframe src="http://www.google.com"></iframe>
An user types a word in google's search engine and clicks on search button (inside iframe) the iframe renders a new page about the search page and again the user clicks on some link inside it, iframe renders a new page ,I want to retrieve the url for which the user click on it inside the iframe.
The only way to do this would be via Javascript. If you give the iframe an id, such as iframeId, you can do something like:
document.getElementById("iframeId").contentWindow.location.href
I googled on other website,but there is no solution for this,iframe tag is built to view contents of the page only,like frameset.
As developers we need to disable external clicking from the user inside the iframe content as it violates some hacking from other website content.
Lets say i have a website called http://123.com.
The index.html page of the website contains an iframe called theframe.
i have three different page (1.html, 2.html, 3.html) for the iframe content and they will be displayed when i click specific button in the site. The default content of the iframe is 1.html.
My question is, if i need to share http://123.com with 2.html or 3.html displayed on the iframe, how should i write the link on facebook/blog/IM to share? Is there a way without modifying the website?
Thank you.
you have hard coded value in iframe src
use querystring
make a parameter named dstntn palce in your url
http://123.com/?dstntn=your_url
and then get it in a var by $_REQUEST['dstntn'];
and give var to iframe src
then change iframe by changing dstntn value by 1.html || 2.html
NOTE: read encoded and decoded form for query string i think dots are not acceptable
I use the same iframe in multiple pages of my web application. I want to have the iframe load once on the login screen and then when brought to the next page the same exact iframe will still be loaded and not refreshed.
Is there any way to keep a part of a webpage loaded and static when directed to the next page? Some sort of static footer with the iframe would be great.
Any help is appreciated thanks.
In the case of submitting a form or using a link, you can target yet another Iframe on the page. The target will load the new page, leaving the original alone.
I am making a tiny bot-like page that will redirect the user to a certain page plus a paramater.
Basically:
A page inside an iframe redirects the user to a random page on my site (already done)
The script appends ?action=purge to the page inside the iframe
The script refreshes the page after 1 second (already done)
The part I need is the middle part, I have no idea how to do that. I know you can use the meta refresh to redirect, but how do you make it so the URL reads the iframe's URL plus ?action=purge"
Try this:
var src1 = document.getElementById('id_of_the_iframe').getAttribute('src');
var src2 = src1 + '?action=purge';
document.getElementById('id_of_the_iframe').setAttribute('src',src2);
If this doesn't work or is not what you are looking for then I don't know.
Edit:
Make sure you call the script after the page has loaded, since you can't change what hasn't been loaded into the DOM in a page yet.