Skip to content

Commit

Permalink
Adding in cross-browser onbeforeunload support. Fixes #4106.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeresig committed Dec 7, 2009
1 parent 1fe9ff5 commit aea5b09
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/event.js
Expand Up @@ -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(" "),
Expand Down Expand Up @@ -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;
}
}
}
}
};
Expand Down

0 comments on commit aea5b09

Please sign in to comment.