javascript windows-detecting status - cant detect status of opened window
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 posted this at 02:05 — 19th June 1999.
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
----------
John Pollock
http://www.pageresource.com
Java Script: A Beginner's Guide
Page Resource
tazman posted this at 19:53 — 24th June 1999.
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
tazman posted this at 02:02 — 25th June 1999.
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 posted this at 03:15 — 25th June 1999.
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
Java Script: A Beginner's Guide
Page Resource
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.