【发布时间】:2013-03-19 20:32:14
【问题描述】:
这是我的代码:
$(window).on('beforeunload', function() {
if ($('.jqmCustomize').css('display') == 'block')
return 'You have not save your customization yet.';
});
这在 chrome 和 firefox 上运行良好,但在 Internet Explorer 上,当我的灯箱在同一页面中打开时,它会触发 on('beforeunload') 事件。有什么办法可以防止这种情况发生吗?我试图:
var close=true;
window.onbeforeunload = closeConfirmation;
function closeConfirmation(){
if(close)
return 'You have not save your customization yet.';
}
但我仍然得到相同的结果。
【问题讨论】:
-
你能详细解释一下这个问题吗?你的
.jqmCustomize是什么,灯箱是什么,你想做什么? -
.jqmCustomize 是我使用 jqmodal 插件的灯箱。我正在检查 jqmCustomize 是否可见,而不是在关闭页面之前询问用户是否要关闭,因为他们将有一些数据要保存在 jqmCustomize 上。这在 chrome 和 ff 上运行良好,但在 ie 上,当 jqmCustomize 灯箱打开时,即认为用户单击了关闭页面按钮,并触发 onbeforeunload。
标签: javascript jquery internet-explorer onbeforeunload