Author |
Topic  |
|
TerryG
Junior Member
 
United Kingdom
179 Posts |
Posted - 29 October 2002 : 10:51:21
|
Using the following example, the closeWindow() function fails to find the window it should close if I refresh the page before using it, anyone explain why please? (and poss how to get around), ta.
<HTML> <HEAD> <TITLE>Untitled Document</TITLE> <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </HEAD> <SCRIPT> var winX = null; function NewWindowX(){ winX = window.open() if(winX.window.focus){winX.window.focus();} } function closeWindow() { if(!window.winX){alert("cant find winX")} else if(winX.closed){alert("winX Closed")} else {winX.close();} } </SCRIPT> <BODY bgcolor="#FFFFFF" text="#000000"> <FORM name="form1" method="post" action=""> <BR> <INPUT type="button" name="Button" value="Open Window" onClick="NewWindowX()"> <BR> <INPUT type="button" name="Button" value="Close Window" onClick="closeWindow()">
</FORM> </BODY> </HTML>
|
|
Kat
Advanced Member
    
United Kingdom
3065 Posts |
|
TerryG
Junior Member
 
United Kingdom
179 Posts |
Posted - 29 October 2002 : 12:00:43
|
When user selects item from a drop down list I want to display a message in a new pop-up window along the lines of "Getting data....won't be long" while I pull a big recordset out of a slowish database, manipulate it and send it back to the browser over a slow link.
The code I gave above is just to demonstrate the problem.
Its easy enough to open the pop-up window and display the message when I submit the form, but I want to close it using something like <BODY OnLoad="closeWindow()"> so that when the page refreshes it closes the window. However once the page has refreshed the closeWindow() function cant find the window I want it to close. It finds it fine before the refresh though. |
 |
|
Kat
Advanced Member
    
United Kingdom
3065 Posts |
Posted - 29 October 2002 : 12:04:53
|
Why do you need to do it that way - can't you do it with a timer telling the secondary popup how many seconds to go before it should close itself? |
KatsKorner
Installation Help | Snitz Mods | Forum Hosting
|
 |
|
TerryG
Junior Member
 
United Kingdom
179 Posts |
Posted - 30 October 2002 : 03:48:23
|
The page is on an intranet, and I am thinking of users connecting via VPN connections with analog modems, however it will also be used by staff connected via big fat kilostream lines which will be loads faster than the analog modems, hence page load could be anything from 0.5 secs to 5+ secs. |
 |
|
RichardKinser
Snitz Forums Admin
    
USA
16655 Posts |
Posted - 30 October 2002 : 05:39:24
|
is it possible that after the refresh, the window loses focus? |
 |
|
TerryG
Junior Member
 
United Kingdom
179 Posts |
Posted - 30 October 2002 : 08:19:22
|
I dont think so, after the refresh the window still appears to have focus, and whether I click it or not to ensure it has focus it seems to make no difference, having refreshed it can't find the window it should close.
I keep wondering if its some kind of security thing, something like you cant write to or close a window unless it is from the window that created it in the first place ( I just made that up, but you know what I am getting at). |
 |
|
TerryG
Junior Member
 
United Kingdom
179 Posts |
Posted - 30 October 2002 : 08:56:01
|
Just found out that if I open two instances of the page which creates the pop-up window (using the code in my first post), only the page which creates the new window can close it. No refreshes involved. I suppose it must be a security thing as mentioned in my last post. |
 |
|
|
Topic  |
|