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

Q648 A window has two pop-up windows, how can I close a pop-up window by clicking a link text in another pop-up window and load a different page in the main window at the same time?

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

Try:

<SCRIPT LANGUAGE="JavaScript"><!--
function doit() {
    opener.otherWindowName.close();
    opener.location.href = 'anotherpage.htm';
}
//--></SCRIPT>

<A HREF="javascript:doit()">...</A>

This works if you've opened your two windows using:

<SCRIPT LANGUAGE="JavaScript"><!--
windowName = window.open('firstpage.htm'); // the one doing the closing
if (!windowName.opener)
    windowName.opener = self;

otherWindowName = window.open('secondpage.htm'); // the one being closed
//--></SCRIPT>

©2018 Martin Webb