Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q963 How can I control the loading of two child windows from a third child window, so that a list of links is loaded alternatively in the other two windows?

irt.org | Knowledge Base | JavaScript | Window | Q963 [ previous next ]

Q963 How can I control the loading of two child windows from a third child window, so that a list of links is loaded alternatively in the other two windows?

If the main window opens three windows named winA, winB and winC, then:

In winA:

<script language="JavaScript1.2"><!--
var myUrls = ['http://www.irt.org','http://developer.netscape.com','http://www.microsoft.com'];

var hitcount = 0;

function goB() {
    if (hitcount < myUrls.length) {
        opener.winB.location.href = 'myFrameB.htm?' + escape(myUrls[hitcount]);
        hitcount++;
    }
}

function goC() {
    if (hitcount < myUrls.length) {
        opener.winC.location.href = 'myFrameC.htm?' + escape(myUrls[hitcount]);
        hitcount++;
    }
}
//--></script>

And then in myFrameB.htm:

<script language="JavaScript"><!--
var output  = '<frameset rows="100%,*" onLoad="opener.winA.goC()">'
    output += '<frame src="' + unescape(location.search.substring(1)) + '">
    output += '<frame src="about:blank">
    output += '<\/frameset>';

document.write(output);
//--></script>

And then in myFrameC.htm:

<script language="JavaScript"><!--
var output  = '<frameset rows="100%,*" onLoad="opener.winA.goB()">'
    output += '<frame src="' + unescape(location.search.substring(1)) + '">
    output += '<frame src="about:blank">
    output += '<\/frameset>';

document.write(output);
//--></script>

This should load the urls in winA alternatively in winB and winC.


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.