Click to See Complete Forum and Search --> : Linking Simultaneously to Multiple Iframes


ahattemer
02-22-2003, 12:38 AM
Simple Question, Is there any way to have a link that, when clicked, loads two different Iframes on the same page? Maybe some kind of JAva script even? Please help!!

Thanks - andy

PeOfEo
02-22-2003, 01:11 AM
With the same page in each or different pages?

AdamGundry
02-22-2003, 04:52 AM
If you have IFrames like this:

<iframe id="page1" src="page1.html">
<iframe id="page2" src="page2.html">

you can use the following code to change both at once:

<a href="javascript:top.page1.src = 'page3.html';top.page2.src = 'page4.html'">Click Me</a>

This Javascript code changes page1 to page3 and page2 to page4.

Hope this helps

Adam

Charles
02-22-2003, 06:42 AM
That will fail one in ten times. Your better bet is create another page that "hard codes" the content of those two IFRAMES and then have your link load that page at the top. Or as an alternate:

<script type="text/javascript">
<!--
document.write('<a href="#">Click Me</a>');
document.links[document.links.length-1].onclick = function () {top.page1.src = 'page3.html'; top.page2.src = 'page4.html'; return false}
// -->
</script>
<noscript>
<p>You will need to click both of these:</p>
<ul>
<li><a href="page3.html" target="page1">Navigation</a></li>
<li><a href="page4.html" target="page2">Content</a></li>
</ul>
</noscript>

Charles
02-22-2003, 07:14 AM
While Mr. Clark's method ought not to be used because of the reasons he has rightly mentioned, it does have one great advantage over Mr. Gundry's method. Mr Gundry's method will also not work with version 6 browers.

ahattemer
02-22-2003, 12:34 PM
Thank You all for the advice, I am testing both methods now.