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

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

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

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

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?'


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.