Link to home
Start Free TrialLog in
Avatar of wibleb
wibleb

asked on

Determining if a child window exists

I have a window that might possibly generate a child popUp window.  If one or more postbacks after a popup window was generated certain things change on the parent window, I want to refresh the data on the popup window.   I have no way of knowing if the popup window was ever created or if it is still open.   Below is some sample code.

var popupWindow;

function OpenPopup()  {                                          
    popupWindow = window.open("Popup.aspx", "pop", opts);
    popupWindow.focus();
}      


A reference to the new Window is assigned to the popupWindow variable during the rendering of the page, but after one or more postbacks, the popupWindow variable is null and no longer points to the existing popup window.   I can get the reference back by running the following code.

popupWindow = window.open("", "pop");
popupWindow .document.Form1.submit()

This works great if the popup window exists.  But if it does not then it just generates a new blank window which is bad.  My goal is to refresh the popup window if it exists but to do nothing if it does not exist already.   Is it possible to know if a window named "pop" exists without actually opening a new window if it does not exist?

ASKER CERTIFIED SOLUTION
Avatar of devic
devic
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wibleb
wibleb

ASKER

devic

This does not help me with my problem.  If you read my question carefully you will see that I need to know if a window exists when there is a postback between the time the window opened and the time I need to make the check.  On your pages, open up some popup windows, and then hit refresh on the parent page.  When you perform the check, it will always say the popup windows are closed even though they are not.  You can re-establish the reference by running code like

popupWindow = window.open("", "popupWindowName");

but it will open a blank window if the popup is not open.  


But don't fret, in what I consider a major flaw in this sites design, I am pretty sure I will end up giving the points to you anyways.  I am nearly certain that the answer is that it is not possible to do what I am trying to do, but I am forced to give the points to somebody.  
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wibleb

ASKER

mr_eqyptian

I believe this has the same problem as devic's.  You are assigning the popup window reference to a page variable.   Whenever there is a postback (such as refreshing the page), it clears all variables.  Try using your code to open a window, hit refresh, and hit check window.  It will say the popup window is absent even though it is still open.
wibleb, you are right.

we spoke some days ago about similar thema, and a solution was with cookie:
http:Q_21152932.html#12221611

I belive this is what you need.