關閉頁面時,彈出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 '確定要關閉窗口嗎>現代瀏覽器?';
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM