【问题标题】:Disable onbeforeunload in Iframe在 iframe 中禁用 onbeforeunload
【发布时间】:2016-06-06 05:55:41
【问题描述】:

我在页面中有一个 iframe ,但是其中有 window.onbeforeunload ,如何禁用它?

window.onbeforeunload = function(){ return "Reload?" }

谢谢!

【问题讨论】:

    标签: javascript jquery onbeforeunload


    【解决方案1】:

    window.onbeforeunload = null;

    这将用于禁用该事件

    【讨论】:

    • 我应该在哪里写?在 iframe 之前还是之后?
    • 要在 iframe 上生效,请尝试类似 document.getElementById('iframe id').onclick = function () { window.onbeforeunload = null; };
    • @NagaSaiA 上面的建议不起作用。处理程序位于 iframe inside 的文档上,而不是 iframe 本身。在该事件处理程序可访问的级别,window 仍然指向包含框架,而不是 iframe。
    猜你喜欢
    • 2012-04-12
    • 2013-07-22
    • 2010-12-08
    • 1970-01-01
    • 2016-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多