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

Q874 How can I get the window handle of an already opened window?

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

Unless you store the window handle at the time you create the window then you can use the solution described in FAQ 782.

You can store a window handle using:

<script language="JavaScript"><!--
windowHandle = window.open('http://www.irt.org','windowName','height=640,width=480');
//--></script>

If you replace the document in the window that opens the popup window then the windowHandle variable is lost. If you need to maintain the window handle then you could consider using a frameset within the main window that uses a hidden frame - so as to make the window look as though its not using frames - and store the window handle in the parent frame:

<script language="JavaScript"><!--
parent.windowHandle = window.open('http://www.irt.org','windowName','height=640,width=480');
//--></script>

This windowHandle variable will then persist, even if the current documents location is changed - but not if the parent frames location is changed.

Feedback on 'Q874 How can I get the window handle of an already opened window?'

©2018 Martin Webb