'Hyperlink to web page with frame and specify frame content from hyperlink
Apologies if this has been answered. I can’t find a simple answer. All pages I am referring to are mine on my website. Put simply I have a page A.html in which I want a hyperlink to my page B.html which contains an iframe. Now from the hyperlink on page A I also want to specify what web page should be loaded in the iframe in page B. So the hyperlink in page A needs to say: Load page B and also load [any web page of my choice specified in the hyperlink] in the frame in page B.
UPDATE: I think I've worked out how to do it thanks to https://rfwilmut.net/notes/iframe.html
How I solved the problem:
In the header section of the page(s) you want loaded in the iframe. Copy and paste - no changes needed.
enter code here`<script>
if (top.location == self.location) {
top.location.href="index.html"}
</script>
In the body section of the page where you want the frame copy and paste the script below - in place of the usual definition. You need to make the following changes: change Pagex to the page you want to be the default page in the iframe change frame1 to whatever you name your frame
<script>
lastp = document.referrer
var fpage = ("Pagex.html");
slsh = (document.referrer.lastIndexOf('/'))
nme = (document.referrer.substring(slsh +1))
if (nme == "") {nme = fpage}
document.write('<iframe src=' + nme + ' name="frame1" style="border: 0px solid ; height: 500; width: 850;" scrolling="auto"></iframe>')
</script>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|