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

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?

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

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?

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>

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.