[Javascript] How to test existence of a window BUT NOT create it

David T. Lovering dlovering at gazos.com
Mon Jul 14 00:40:36 CDT 2003


I may be completely off-base on this, but since a window is an ordinary DOM object, it might be possible to
simply do an "if" check, thusly:

  if (!win) {
    // do whatever you'd do if the window wasn't there
  } else {
    // do whatever you'd do if it was
  }

where "win" is the window ID you presume MIGHT be there.  I've used this approach in several code modules,
and so far nothing has blown up.  [Might you, under JScript the rules for testing window existence are slightly
different, so this approach may lack universality].  Also, I believe it is still possible to "walk-the-tree" of
the object thread, thereby discovering which window objects are in place -- including ones behind the active pane
or placed outside the viewable window space.

-- Dave Lovering

Stevel Lintz wrote:
> 
>    Part 1.1.1    Type: Plain Text (text/plain)
>              Encoding: quoted-printable
> 
>    Part 1.2    Type: Plain Text (text/plain)
>            Encoding: 7bit
Given the (string) name of a window, how can I test if it's open without
also causing it to be created (if it's not previously extant)?  The only way
I know to obtain a reference to a window is by using window.open() - but
this will always create the window if it doesn't currently exist, which is
what I need to avoid.

 

TIA!

-Stevel


More information about the Javascript mailing list