Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to load an html page into an iframe on another page. In other words, in one click:

1) Starting from the first page, open the second page (index.html, in the same window) containing an iframe ('frame1').
2) Then load a third page (info/aboutSiteDev.html) inside the iframe ('frame1') on the second page (index.html) that was just loaded.

My research lead me to two pieces of code that don't seem to work (see below).

What am I missing?

Any help would be greatly appreciated.

What I have tried:

HTML
<a href="#" onclick="window.open('index.html','_self'); parent.document.getElementById('frame1').src = 'info/aboutSiteDev.html'">Website Development Info</a>

HTML
<a href="index.html?displayFrame=info/aboutSiteDev.html">Website Development Info</a></p>

The iframe getting referenced on index.html is:
HTML
<iframe id = "frame1" name = "displayFrame" src="/core/home.html" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" title="Display iFrame"></iframe>

But both don't seem to work. They do open index.html, but they don't seem to affect the iframe. I've tried swapping out the id for the name with the first method, to no avail. The code "parent.document.getElementById('frame1').src" does work when executed on the second page itself, but not when I'm executing it from the first page.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900