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

Q215 Is it possible to close the parent window (main web browser window) from a child window?

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

Q215 Is it possible to close the parent window (main web browser window) from a child window?

Put the following in the child:

<script langauge="JavaScript"><!--
opener.close();
//--></script>

Although you'll need to make sure that the opener has been defined for browsers that don't have it by default, by placing the following in the parent:

<script language="JavaScript"><!--
msgWindow=open('',window,'resizable=no,width=200,height=200');
msgWindow.location.href ='apage.html';
if (msgWindow.opener == null) msgWindow.opener = self;
//--></script>

Note, that this will likely prompt the user for confirmation before closing the window.


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.