【问题标题】:beforeunload in Microsoft Edge not firingMicrosoft Edge 中的 beforeunload 未触发
【发布时间】:2019-09-13 17:48:13
【问题描述】:

我在我的 js 代码中添加了beforeunload,如下所示,它适用于 IE10 我想给用户一个警告,别无其他

$(document).ready(function () {
    init();
    window.addEventListener("beforeunload", function () {

        if (changeSubmitted) {          
            return 'If you choose to leave, the data entered will not be saved!';

        }
        return true;

    });
});

codepen

但是,该事件似乎没有在 Edge 中触发。

【问题讨论】:

    标签: javascript microsoft-edge onbeforeunload


    【解决方案1】:

    不幸的是,所有主要浏览器都删除了对 onbeforeunload 事件中自定义消息的支持,现在它们只显示自己的通用文本。除了 IE :)

    看看browser compatibility list

    【讨论】:

      猜你喜欢
      • 2018-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-01
      • 2020-12-08
      • 1970-01-01
      • 1970-01-01
      • 2017-10-16
      相关资源
      最近更新 更多