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()">