View Full Version : Check for Child window & close if open..
Jodda
07-01-2002, 05:37 PM
There are 3 files involved with a process, 1 that gatheres files, 2'nd Processes files & the 3'rd is a file (results page) opened in a popup window from the 2'nd. When the popUp window is opened, the 2'nd page is replaced by the 1'st page, ready for the start of another process. But how do i check to see if the popUp window is there for when the user reaches the second page again.
At the moment if the popUp window is open when another process is activated, the popUp window is not refreshed with the new results. I'd like to close the popUp window before opening it again.
tamienne
07-01-2002, 09:02 PM
one way to do it is to open it then close it right after.
function closePopups() {
var popUp=window.open("blank.htm","name of the popup window","width=1,height=1");
popUp.close();
}
<BODY onLoad="closePopups()">
by opening it again you get the window handle (if it exists) so you can close it.
glenngv
07-02-2002, 03:30 AM
Originally posted by Jodda
At the moment if the popUp window is open when another process is activated, the popUp window is not refreshed with the new results. I'd like to close the popUp window before opening it again.
how do you open the popup window from the 2nd file?
Jodda
07-02-2002, 09:46 AM
Hi,
Open the results page, from page 2 like this:
var CenW = (screen.width - 760) /2;
var CenH = (screen.height - 480) /2;
lWin=window.open("dl_onlineDemo_scanresults.asp","lWin","width=760,height=480,top="+CenH+",left="+CenW+",scrollbars=yes,resizable=yes");
If you try and Alert(lWin) - comes back with 'undefined', so i tried an If>Else with 'undefined' and that returned an error too.
Maybe its loosing the (popUp win) name and any recognition with the (popUp Win) when the opener page is unloaded?
As an alternative i could create a boolean variable inside a session object with 'asp', then write the session var as a JS var, then do a check on the JS var to see if the popUp win is open, but i was sure JS would be able to do a check?
glenngv
07-02-2002, 10:14 AM
This:
lWin=window.open("dl_onlineDemo_scanresults.asp","lWin","width=760,height=480,top="+CenH+",left="+CenW+",scrollbars=yes,resizable=yes");
...should always open the "updated" page unless the asp page produce the same result in every instance.
What factor would the asp page change its content?
At the moment if the popUp window is open when another process is activated, the popUp window is not refreshed with the new results.
Jodda
07-02-2002, 11:07 AM
The asp page outputs a session var that holds html output from a .dll, i see where your going and your right, on the second time round, if the window is open, the asp page within the popUp window is not refreshed.
On the second time around if i right-click --> Refresh, the content changes.
Is there a refresh() command in JS?
Jodda
07-02-2002, 12:19 PM
Are right, part of the location object, added this to the end of the code above and all is fine, cheers both:
lWin.location.reload();
lWin.focus();
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.