Dr. Web
06-19-2001, 02:17 PM
The following script creates a pop-up. This pop-up will close if the parent window is closed. So far, so good. But, the problem lies in that if the child window is not present, then a javascript error is generated, stating that the variable win is undefined. It is, because the pop-up is not open. The goal here is to use the pop-up as a help page. If the surfer exits the main page, while the help pop-up is open.... it should close too. If the surfer exits (and the help pop-up is not open) nothing happens.
Just need some ideas! Thanks in advance!
<html>
<head>
<title>Untitled</title>
<script language ="javascript">
function pop_up(){
win = window.open("http://www.yahoo.com", "dep", "height=1,width=1", hotkeys="no");
}
function closeDep() {
if (win && win.parent && !win.closed) win.close();
}
</script>
</head>
<body onUnload="closeDep();">
<a href="#" onclick="pop_up();">Yahoo</a>
</body>
</html>
Just need some ideas! Thanks in advance!
<html>
<head>
<title>Untitled</title>
<script language ="javascript">
function pop_up(){
win = window.open("http://www.yahoo.com", "dep", "height=1,width=1", hotkeys="no");
}
function closeDep() {
if (win && win.parent && !win.closed) win.close();
}
</script>
</head>
<body onUnload="closeDep();">
<a href="#" onclick="pop_up();">Yahoo</a>
</body>
</html>