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

Q1476 How do I close a child window right after the parent window closes?

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

In Netscape Navigator 4+ and Internet Explorer 4+ if you open it with:

<script language="JavaScript"><!--
theChild = window.open('apage.htm','windowname','width=640,height=480');
//--></script>

Then you can close it with

<body onUnload="if (theChild && !theChild.closed) theChild.close()">

This will close it if the user leaves the page that opened it. If you need to have the child stay open across multiple pages, you need to open it from a frameset and put the onUnload in the frameset tag:

<frameset onUnload="if (theChild && !theChild.closed) theChild.close()">

Feedback on 'Q1476 How do I close a child window right after the parent window closes?'

©2018 Martin Webb