PDA

Click to See Complete Forum and Search --> : <body onclose=iWish()>


billyo
Jul 18th, 2000, 04:07 AM
Does anybody know of a relatively simple way for a page to discern whether or not the user is merely unloading the page, or if they've "x-ed out" the browser? I'd like to do it without any irritating popup windows, but I can't think of any other way.

Also, do it with the popup window I've tried using something like:

if (window.opener)
{
//okay so this is true in the popup window
}
if (window.opener.location)
{
//this will also be true in a popup window whether or not
//the parent window has been closed.
window.opener.location="http://someurl.com"
//this will cause an error if the parent window has been closed
//so if I could force the error and then trap it it could work
}

So my second question is: how does one trap errors reliably in IE5? The window.onerror=function() seems to call the errorhandling function even when it is the only code in the page, and then it will go on to spew several other errors about "not being implemented" and "expecting some object" etc...

Jul 19th, 2000, 01:29 PM
Are you trying to open a popup window when the main window is closed.

<html>
<SCRIPT LANGUAGE="JavaScript">
function byebyewin(){
windowLeaving=window.open("",'Leaving','toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=1,width=420,hei ght=420');
windowLeaving.document.writeln("<head><title>Leaving so soon?</title></head><body bgcolor='black' text=white>");
windowLeaving.document.writeln("<h2><center>Before you go...</h2><BR>");
windowLeaving.document.writeln("<h4>Don't forget to come back and visit.</h4><BR>");
windowLeaving.document.writeln('<h3><center>And check out these sites:</center></h3><BR>');
windowLeaving.document.writeln('<a href=http://www.vb-world.net/ target=new>');
windowLeaving.document.writeln('Vb-World.net');
windowLeaving.document.writeln('</a><BR>');
windowLeaving.document.writeln('<a href=http://forums.vb-world.net/ target=new>');
windowLeaving.document.writeln('Vb-World.net Forums');
windowLeaving.document.writeln('</a><BR>');
windowLeaving.document.writeln('<a href=http://www.planet-source-code.com/ target=new>');
windowLeaving.document.writeln('Planet-Source-Code.com');
windowLeaving.document.writeln('</a><BR>');
windowLeaving.document.writeln('<a href=http://www.vbcode.com/ target=new>');
windowLeaving.document.writeln('Vbcode.com');
windowLeaving.document.writeln('</a>');
}
</SCRIPT>

<body onunload="byebyewin()">
</body>
</html>

billyo
Jul 19th, 2000, 02:27 PM
no, i'm trying to determine if the window that opened the popup is still there or not without having the code spew error messages. and I'm trying to only have to open the popup if the window is being closed, not merely unloaded.