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

Q1048 How can I close the child window when I close its opener?

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

Use the window handle:

<script language="JavaScript"><!--
var windowHandle = -1;

function myOpen() {
    windowHandle = window.open('page.htm','windowName','width=640,height=480');
}

function myClose() {
    if (windowHandle != -1)
        windowHandle.close();
    setTimeout('self.close()',1000); // 1 second delay before closing self
}
//--></script>

©2018 Martin Webb