Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q1255 What do I need to know about window names?

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

You open a new window in one of three ways:

1. start the browser
Internet Explorer's main browser is _main (undocumented)
Netscape Navigator's main browser is namesless but can be given a name since v3:


or from a window opened by the main window:


2. Using target on frame, href or form
The following:

<A HREF="popup.html" TARGET="popup">open page</A>

will open popup and load page the first time and just load page if popup is already open

3. using window.open

windowHandle = window.open('page.html','popup',properties);

There are exceptions to the name rule - if the "magic" targets/windownames: _top, _self, _blank are used, the opened window will be nameless, but can in situation 3 be given a name:

windowHandle.name = 'popup'; // (a bit pointless...)

You can determine the name of the current window by asking and/or setting it:

if (!self.name) self.name = 'myWindow';

You can get the windowHandle, which you will need to do things like closing or resizing a window by opening the window if you know the name:

winHandle = window.open('','windowName');

Be aware that Internet Explorer 3 does not like this lack of page name and will open a blank window.

A trick to close a named window would then be to load a page that closed itself:


Where closeit.html contained:

<BODY onLoad="self.close()"></BODY>

This will produce a warning if you didn't open that window yourself and if the history of that window contain more than one entry.

©2018 Martin Webb