I'm a bit confused, why this
window.onbeforeunload = function () {
socket.emit('foo')
}
does nothing, while this
$(window).on("beforeunload", function () {
socket.emit('foo');
});
Makes the job done on chrome 42.0.2311.90 m
What is the difference?
And how reliable jQuery
version is?
I want to use onbeforeunload
to distinguish disconnect
event while user leaves the app from disconnect
event while something terribly failed in socket connection on the server or user side.