[thelist] How to get the handle of the window using the name

Richard Bennett mail at richardinfo.com
Tue Nov 27 14:58:51 CST 2001


Hi,
----- Original Message -----
From: "Aryakumar K George" <akgeorge at snb.psi.soft.net>

> Hi,
> Thank you very much for the information, but the solution you have given
is
> after getting the handle. At the time of getting the handle script 'OPEN'
> will open the window if it doesn't exists. I want to check whether window
> exists before this itself, ie: before actually doing the script 'OPEN'.

> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of Peter-Paul Koch
>
> if (win && !win.closed)

If the problem is that the variable "win" may not be declared yet, and thus
this object test is causing errors, do this:

<tip type=javascript>
If you want to test whether a variable has been defined or not,
simply calling it by name will cause an error if it has not yet been
declared:

if(win)
causes error,

var win=true
if(win)
is ok.

So you can do two things, either attach the variable to an object you're
sure will be declared, like this:

if(document.win)
Is ok

document.win=true
if(document.win)
is also ok,

OR, test for it like this:

if(self["win"])

Now that's cool!

</tip>

Richard Bennett.






More information about the thelist mailing list