Closing browser window

admin

Administrator
Staff member
In one of the pages on my site, I am opening a pop up window which contains other links. When a user logs off on the parent browser, the parent browser closes. But the popup browser is still open and I can navigate to all other links on it. Is there a way to shut down the popup window once the main window closes?<!--content-->Yes, there is a way to close a "child" window on exit of the parent window....or any window for that matter. What you have to do is name your pop-up, and then onUnload of your parent page...look and see if the child is open. if it is...close it. Its called making a child a "dependant" window, and here is the bread-n-butter:<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><br />
<br />
<br />
[Edited by Dr. Web on 03-07-2001 at 05:09 PM]<!--content-->
 
Back
Top