How to detect IE window close (X) action by user?

  • Thread starter Thread starter Guest
  • Start date Start date
This question comes up time and time again.

Generally speaking, there is no way for the server to know if the client
browser has been closed, or even if the client has navigated to another
website.

This is because of the fundamental architecture of the web.

The server waits for an incoming HttpRequest.

The server processes the incoming HttpRequest.

The server sends back an HttpResponse.

The server waits for an incoming HttpRequest. If no incoming HttpRequest
arrives, there's nothing the server can do about it...

There have been various possible solutions suggested, mainly to do with the
<body onload> method, but none is satisfactory...

Why do you need to know this anyway...?
 
in javascript catch the onbeforeunload or onunload event, and check the
event x & y positions (they will be off srceen). its a hack.

-- bruce (sqlwork.com)
 
As above, catch the body.unload event and fire a postback event from
Javascript to tell the server the page is closing.

The only draw back is that is will fire when the user closes the
browser and when they move to a different page.


Fran

http://www.bluejumper.com
 
As above, catch the body.unload event and fire a postback event from
Javascript to tell the server the page is closing.

The only draw back is that is will fire when the user closes the
browser and when they move to a different page.

That's right - so not much use for any website which has more than one
page...
 
Back
Top