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

Q1252 How do I close a pop-up window if I only have the name of the frame?

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

You can open a new file in the window you want to close by calling window.open('empty.html', 'nameOfWindow') within the main window. Place a window.close() call in empty.html. This will make the first window to open the empty.html in the window you want to close, empty.html will then close the window by itself. Not the best solution perhaps - but it works!

Within the main window:

<script language="JavaScript">
// <!--
    window.open('empty.html', 'nameOfWindow');
//-->
</script>

Within empty.html:

<script language="JavaScript">
// <!--
    window.close();
//-->
</script>

Submitted by John K. Son

©2018 Martin Webb