From: John Resig Date: Mon, 7 Dec 2009 00:55:08 +0000 (-0800) Subject: Adding in cross-browser onbeforeunload support. Fixes #4106. X-Git-Tag: 1.4a2~94 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aea5b091954b3c823b318b392660b22c7b1e978a;p=jquery.git Adding in cross-browser onbeforeunload support. Fixes #4106. --- diff --git a/src/event.js b/src/event.js index bf7798bb7..d9401c99e 100644 --- a/src/event.js +++ b/src/event.js @@ -327,6 +327,8 @@ jQuery.event = { } } + + return event.result; }, props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), @@ -432,6 +434,21 @@ jQuery.event = { } }, special: {} + }, + beforeunload: { + setup: function( data, namespaces, fn ) { + // We only want to do this special case on windows + if ( this.setInterval ) { + this.onbeforeunload = fn; + } + + return false; + }, + teardown: function( namespaces, fn ) { + if ( this.onbeforeunload === fn ) { + this.onbeforeunload = null; + } + } } } };