The way I've approached this in the past, is by using the onunload event,
and a global frameset. The global frameset can consist of one frame, which
contains the website. The frameset has an onUnload event handler attached,
to execute a server-side page when the user navigates away from the site (or
closes the browser). Navigating within the site will happen within the
frame, which won't fire the onUnload event.
E.g.
In the head section, we could have the following script:
<script language="javascript">
function window_onunload()
{
window.open("http://www.domain.com/dosomething.aspx");
}
</script>
Our frameset could consist of the following:
<frameset rows="100%" onUnload="window_onunload()">
<frame name="MainFrame" src="default.aspx" marginwidth="0"
marginheight="0" scrolling="auto" frameborder="0">
</frameset>
It's not quite the same as the browser firing an event when it's closing.
However, the above method can be applied to achieve relatively good results.
But, as a precaution, I agree that it's always best to use the Session_OnEnd
event, as this is the only reliable way to catch the end of a session and
the browser being closed down.
Mun
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Now, Id' surely like to know how the browser is supposed to send a request
when it is closing. The only reliable way to snag the end of the browser
session is with the Session_OnEnd event.
--
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.