View Full Version : detecting when window is closed.

10-16-2003, 08:40 PM
i found this explanation from another board for detecting when a window is closed (not refreshed or switching to another page, but actually closing the browser window). how would i invoke this in the popup that checks the status of the main window?

"Open a small popup off screen to detect for self.opener.closed() if true then the end the session and close the popup."

10-16-2003, 08:47 PM
problem with this is when the page is refresheded the popup looses the parent object so it will think it is closed.

10-16-2003, 08:49 PM
is this true for when a user just goes to another page also?

10-16-2003, 08:52 PM
actually, if you refresh, the popup get redrawn, so i think it will work ok. i just need to know how that popup checks the bottom window to see if it's closed or not. do i use a settimeout or something that runs a function that checks it?

10-17-2003, 03:51 AM
Is this for IE only?

function doUnload()
if ( window.event && window.event.clientX < 0 && window.event.clientY < 0)
//the browser is closed
alert("browser closed.");
<body onunload="doUnload()">