Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Cant close window after page refresh
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

TerryG
Junior Member

United Kingdom
179 Posts

Posted - 29 October 2002 :  10:51:21  Show Profile
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

Posted - 29 October 2002 :  11:01:11  Show Profile  Visit Kat's Homepage
What are you trying to do exactly?

KatsKorner

Installation Help | Snitz Mods | Forum Hosting
Go to Top of Page

TerryG
Junior Member

United Kingdom
179 Posts

Posted - 29 October 2002 :  12:00:43  Show Profile
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.
Go to Top of Page

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 29 October 2002 :  12:04:53  Show Profile  Visit Kat's Homepage
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
Go to Top of Page

TerryG
Junior Member

United Kingdom
179 Posts

Posted - 30 October 2002 :  03:48:23  Show Profile
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.
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 30 October 2002 :  05:39:24  Show Profile
is it possible that after the refresh, the window loses focus?
Go to Top of Page

TerryG
Junior Member

United Kingdom
179 Posts

Posted - 30 October 2002 :  08:19:22  Show Profile
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).
Go to Top of Page

TerryG
Junior Member

United Kingdom
179 Posts

Posted - 30 October 2002 :  08:56:01  Show Profile
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.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.23 seconds. Powered By: Snitz Forums 2000 Version 3.4.07