我已经看过这个但是它不适合我
var needToConfirm = true;
window.onbeforeunload = confirmExit;
function confirmExit() {
if (needToConfirm)
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
答案 0 :(得分:0)
我能够使用jQuery的IE和FF工作:
$(window).bind('beforeunload', function(){
});