Connecting Tech Pros Worldwide Help | Site Map

Testing if a window is open?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 11:24 AM
laxmi
Guest
 
Posts: n/a
Default 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

  #2  
Old July 23rd, 2005, 11:24 AM
Richard Cornford
Guest
 
Posts: n/a
Default Re: Testing if a window is open?

laxmi wrote:[color=blue]
> Is there a way to test whether a named window is open from
> a separate window which may not have opened the window?[/color]
<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.



 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.