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

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

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

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.

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

©2018 Martin Webb