You are here: irt.org | FAQ | JavaScript | Window | Q793 [ previous next ]
In newer browsers (JavaScript 1.1) you can check that a window is still open using:
if (!windowName.closed)
You can therefore make you code more robust with:
<SCRIPT LANGUAGE="JavaScript"><!-- function focusOpener() { opener.focus(); } //--></SCRIPT> <SCRIPT LANGUAGE="JavaScript1.1"><!-- function focusOpener() { if (!opener.closed) { opener.focus(); } } //--></SCRIPT> <A HREF="javascript:focusOpener()">show main window</A>
The second definition of focusOpener() overrides the first in browsers that support JavaScript 1.1 or better, for other browsers the more unreliable approach is used.