close child window on Netscape

liunx

Guest
Hello,<br />
<br />
How do I close child windows on Netscape? I can use onUnload on IE but it doesn't work for Netscape.<br />
<br />
Thanks,<br />
Katherine<!--content-->hmmmmnn.....I use onUnload and it works in IE and netscape. Can you post a url for us to have a look at? Or post your code. Here is my code for closing a window onUnlad, in both IE and N4.7<br />
<br />
<html><br />
<head><br />
<title>Untitled</title><br />
<script language ="javascript"> <br />
function pop_up(){ <br />
win = window.open("http://www.yahoo.com", "dep", "height=1,width=1", hotkeys="no"); <br />
} <br />
function closeDep() { <br />
if (win && win.parent && !win.closed) win.close(); <br />
} <br />
</script> <br />
</head><br />
<body onUnload="closeDep();"><br />
<a href=http://www.htmlforums.com/archive/index.php/"#" onclick="pop_up();">Yahoo</a> <br />
</body><br />
</html><!--content--><a href=http://www.htmlforums.com/archive/index.php/"javascript:void(0);" onClick="window.close()">hjhjh</A><!--content-->Sorry about that. Yes onUnload is working for Netscape as well. <br />
<br />
How do I close childwindows when the browser is closed?<br />
<br />
Thanks,<br />
Kath<!--content-->Katherine,<br />
The code I posted above does exactly what you want. Open a new browser window with that code running, then press the link to open a new 'child' window. Then close the PARENT window, and you'll see the child close as well.<!--content-->Is there a way to close all child windows at once versus naming each and closing windows one at a time?<br />
<br />
Thanks,<br />
Kath<!--content-->I have a jsp which opens childwindows. After I close the child window (eg. cancel button) I can't open those child windows again? <br />
1. how do I reset child window var (see childA below)?<br />
2. is there a way to close all windows without managing them one by one (eg, via child window var for each child window)?<br />
3. is this the best way to do this? Code gets repetitive ....<br />
<br />
----- Here's what I used to do this ... -----<br />
<br />
<body onUnload=closeChildWindows();><br />
...<br />
<br />
<input type="button" OnClick=OpenWindowA();><br />
<br />
...<br />
<br />
<script language="JavaScript"><br />
var childA;<br />
<br />
function OpenWindowA()<br />
{<br />
if (childA==null)<br />
// window doesn't exist yet<br />
childA = window.open("nextpage.jsp?");<br />
else<br />
// don't open another window just bring to forefront the previous one opened.<br />
childA.focus();<br />
}<br />
<br />
function closeChildWindows()<br />
{<br />
if (childA != null)<br />
childA.close();<br />
}<br />
</script><br />
<br />
</body><br />
<br />
---- end<br />
<br />
Thanks,<br />
Kath<!--content-->Actually, I added this to allow for reopening windows:<br />
<br />
function OpenWindowA() <br />
{ <br />
if ((childA==null) || (childA.closed))<br />
...<br />
}<br />
<br />
<br />
Thanks for all your feedback!<br />
Kath<!--content-->Katherine,<br />
Though I don't know JSP, I have worked alongside it. The best bet here, would be to call a JavaScripot function from the main webpage that is displayed, and this functioon should spawn the child windows. In this manner, you need not bother resetting anything. I am not sure why you would need so many child windows....but to close them all you could just name them in an array fashion. The just include a loop inside your close child function to look for the length of the array, and loop that many times closing any child windows open. <br />
<br />
This too seems like a hassle. What kind of app are you building that requires so many new windows?<!--content-->
 
Back
Top