关闭页面时,弹出JS提示框提示是否关闭

 

JQUERY写法:

$(window).bind('beforeunload', function (e) {
var isEdit = '<%=FormMastPage.ViewMode%>';
if (window.is_confirm !== false && isEdit == Enumerator.ItemViewMode.AllEdit) {
var message = '<%=this.GetRes("Msg_CheckPageEditMode")%>';
e.returnValue = message;
}
})
.bind('mouseover mouseleave', function (event) {
is_confirm = event.type == 'mouseleave';
});

 

JAVASCRIPT写法:

window.onbeforeunload = function (event) {
var event = event || window.event;
// 兼容IE8和Firefox 4之前的版本
if (event) {
event.returnValue = "确定要关闭窗口吗?";
}
// Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
return '确定要关闭窗口吗>现代浏览器?';
}

posted @ 2017-04-17 13:53  SharkLock  阅读(8413)  评论(0编辑  收藏  举报