Harlan Iverson said the following:
Can you elaborate on the dual-handler method and how reliable it is, and
possibly give a code example?
I don't remember exact stats, but it ended up being pretty reliable across
browsers for our needs in disconnecting on a window close - the rare instance of
it not working just had them online for a bit before timing out.
This is a quick example:
function windowOnUnload (ev) {
if (window.app)
app.disconnect();
}
function windowOnBeforeUnload (ev) {
if (window.app)
app.disconnect();
}
util_addEventListener("unload", window, windowOnUnload);
window.onbeforeunload = windowOnBeforeUnload;
util_addEventListener is just a wrapper for using attachEvent/addEventListener
in the right browsers - another quirk to note here is that onbeforeunload
doesn't work properly with those functions, which is why it's being set differently.
--
Collin Grady