View Full Version : Closing Child windows if it exists

10-20-2005, 05:15 PM
I call a function in my code called openPopup which opens a new window. This openPoup function is a function that is used throughout the a site and I cannot change the code, if I could I would put a var myWin = in front of it to reference it.

The code in this function is basically this...


So how do I access this window given that there is no varaible set to it and the name attribute is set to null?

The window might not be open at all so do I check its there and close if it is, I guss there is a way from teh window object to check for children.

10-20-2005, 05:22 PM
open the popup as a variable
var mywin = window.open(url,null,"attributes....");

now you can chech if the variable exists:

if(!mywin){//if the window does not exist
... do something...

or check for boolean true:

10-20-2005, 05:34 PM
Sorry Kor that's not what im after, maybe I didn't explain it well.

I can not edit the popup code. So if i was able to, I would do what you suggested but I can't modify that popup code.

So what Im after is a way to reference the child window, without doing the var myWin = bit

10-20-2005, 05:41 PM
you can not reference otherwise the child popup window.