471,066 Members | 1,191 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Testing if a window is open?

Is there a way to test whether a named window is open from a separate
window which may not have opened the window?
I have tried using:

if(windowname == null)
win = window.open(...)

This gives an error that windowname is undefined

if(window.windowname) doesn't work either (no error, but fails to
detect).

One alternative could be having win as a global Javascript variable.
Are there any other ways ?

Any help is appreciated.
Thanks
Laxmi
Jul 23 '05 #1
1 1221
laxmi wrote:
Is there a way to test whether a named window is open from
a separate window which may not have opened the window?

<snip>

No, the name given to a window as the second argument to the -
window.open - function has no representation in the browser's object
model. To test characteristics of a window you need to have a reference
to the corresponding window object. That reference is returned by the
call to - window.open - but if that window reference is not available
then there is no way of getting it short of calling the - window.open -
function and passing it the same name as the second argument. Pop-up
blockers not withstanding, re-calling - window.open - with the required
name as its second argument will result in a window being opened in the
event that a window with that name was not already open, and navigation
of that window if it was already open but the URL passed as the first
argument to - window.open - is not the URL of the currently displaying
page.

Richard.

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Marshall Dudley | last post: by
3 posts views Thread by NeverLift | last post: by
1 post views Thread by Steve Karnath | last post: by
14 posts views Thread by D. Alvarado | last post: by
7 posts views Thread by anthony.turcotte | last post: by
3 posts views Thread by Ant | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.