一,window.onbeforeunload = function() {
return "确定离开页面吗?";}
二,window.onbeforeunload = function(event) {
(event || window.event).returnValue = "确定退出吗";
}
这个方法chrome和safari不支持,但是由于ie和ff的支持,html5也加入了标准...
大家都知道浏览器的几种弹出对话框都会阻止事件的往下进行,(如alert,confirm),进一步操作后会继续事件的往下执行
一般的做法都会这样
三,window.onbeforeunload = function(event) {
return confirm("确定退出吗");
}