I'd like to submit my very simple solution/replacement for the deprecated .beforeunload() utility.
jQuery.exitIntercept = function(e,msg) {
var message = jQuery.trim(msg);
e = e || window.event;
if (e) {
e.returnValue = message;
}
return message;
}
This small utility is IE/FF/Chrome/Safari safe.
Thanks
Usage: window.onbeforeunload = $.exitIntercept(
"You are attempting to leave this page with unsaved changes! If you leave this page without saving your changes, they will be lost!");