]> source.dussan.org Git - jquery.git/commitdiff
Adding in cross-browser onbeforeunload support. Fixes #4106.
authorJohn Resig <jeresig@gmail.com>
Mon, 7 Dec 2009 00:55:08 +0000 (16:55 -0800)
committerJohn Resig <jeresig@gmail.com>
Mon, 7 Dec 2009 00:55:08 +0000 (16:55 -0800)
src/event.js

index bf7798bb7dbb1977a0c2b3f4e928c5de722d9eca..d9401c99e743ff58c650cf4e57aeb83bad5f27aa 100644 (file)
@@ -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;
+                               }
+                       }
                }
        }
 };