這裏是我的代碼:Internet Explorer的火災時,收藏夾彈出
$(window).on('beforeunload', function() {
if ($('.jqmCustomize').css('display') == 'block')
return 'You have not save your customization yet.';
});
這適用於Chrome和Firefox罰款,但在Internet Explorer,它觸發對( 'beforeunload')當我的燈箱在同一頁面打開時發生的事件。有什麼辦法可以防止這種情況發生?我試圖:
var close=true;
window.onbeforeunload = closeConfirmation;
function closeConfirmation(){
if(close)
return 'You have not save your customization yet.';
}
但我仍然得到相同的結果。
你能解釋這個問題有點更詳細的? 什麼是你的'.jqmCustomize',什麼是燈箱,你想做什麼? – inser 2013-03-19 20:47:13
.jqmCustomize是我使用jqmodal插件的燈箱。我正在檢查jqmCustomize是否可見,比關閉頁面之前,詢問用戶是否要關閉,因爲他們將有一些數據保存在jqmCustomize上。這對鉻和FF工作得很好,但在即,當jqmCustomize燈箱打開,即認爲用戶點擊關閉頁面按鈕,並觸發onbeforeunload。 – 2013-03-19 20:53:46