Why jQuery sometimes overwrites window.onbeforeunload?
I am having strange problem with jQuery (1.6.x). I have this simple call on my page: window.onbeforeunload = function() { return 'Are you sure ?'; }; But it doesn't work, because as I've found out, jQuery overwrites content of the window.onbeforeunload. In JS console, I can see that window.onbeforeunload contains piece of jQuery code: function( e ) { // Discard the second event of a jQuery.event.trigger() and // when an event is called after a page has unloaded return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? jQuery.event.handle.apply( eventHandle.elem,