Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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?

You are here: irt.org | FAQ | JavaScript | Window | Q963 [ previous next ]

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.

©2018 Martin Webb