JQuery reliability

I'm a little confused why this

window.onbeforeunload = function () {
socket.emit('foo')
}

      

does nothing, while this

$(window).on("beforeunload", function () {
socket.emit('foo');
});

      

Does work on chrome 42.0.2311.90 m

What's the difference?

How reliable is the version jQuery

? I want to use onbeforeunload

to highlight an event disconnect

while the user leaves the app from disconnect

, and something horribly failed on a socket connection on the server or user side.

+3


source to share





All Articles