關(guān)閉(不離開)頁面時jquery beforeunload?如何顯示“您確定要離開頁面嗎?” 當用戶實際嘗試關(guān)閉頁面時(單擊瀏覽器窗口或選項卡上的X按鈕),當他試圖離開頁面時(單擊另一個鏈接)。當用戶嘗試關(guān)閉頁面時,我的客戶希望顯示一條消息“您確定要離開頁面嗎?您的購物車中仍有商品?!辈恍业氖?(window).bind('beforeunload'),只有當用戶關(guān)閉頁面時才會觸發(fā)。jQuery的:function checkCart() {
$.ajax({
url : 'index.php?route=module/cart/check',
type : 'POST',
dataType : 'json',
success : function (result) {
if (result) {
$(window).bind('beforeunload', function(){
return 'leave?';
});
}
}
})}
關(guān)閉(不離開)頁面時jquery beforeunload?
慕妹3146593
2019-08-26 17:48:39