javascript windows-detecting status - cant detect status of opened window

They have: 99 posts

Joined: May 1999

I am going a little crazy on this, any help appreciated.
I am launching a new window by using window.open method, I am dynamically loading content with document.write problem is, I need to be able to close / clear the window from the window.opener but cant check the status of the window without getting an object undefined error if the window has been closed already.

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

Do you have the new window set as a variable in the script? It might do the trick.

It would be helpful to see what you have so far, if you could post the script that would be great Smiling

----------
John Pollock
http://www.pageresource.com

They have: 99 posts

Joined: May 1999

John: sorry, I didnt get an email indicating a response posted. I have basically given up trying. I was able to do a work around using cgi. The cgi will refresh the contents of the window if open. I would still love an answer. Basically, is there any way to tell if a window you opened via:
new_win=window.open('source.html','new_win');
is still open? If you just use new_win.close(); and the window is already closed, you get a not an object error. If anyone knows, please advise.

----------
Alan Izat

They have: 99 posts

Joined: May 1999

John:
Thanks for the response. I had tried that and other methods. If the window is already closed, this method generates a javascript error, that, depending on where in the script the call is made, can crash the script. The netscape console shows the error:

JavaScript Error:
http://www.connex-electronics.com/_private2/win1_frames.html,
line 15:

second_win.close is not a function.

The example code is at:
www.connex-electronics.com/_private2/frame_doc.html
(I added the code to my other example)

----------
Alan Izat

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

I think if you check for the existence of the window first, it would work OK. Something like this:

if (new_win)
{
new_win.close()
}

----------
John Pollock
http://www.pageresource.com

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.