[英]onBeforeUnload suddenly not working as expected
I was using this snippet for almost 2 years. 我使用了近2年的这段代码。 It was fine then, until I saw it was not working today on
Google Chrome version 51.0.2704.103m
. 那很好,直到我看到它今天不能在
Google Chrome version 51.0.2704.103m
。
$(window).on('beforeunload', function () {
return "Are you sure you want to exit this page?";
});
It doesn't show my custom message but instead just show: 它不显示我的自定义消息,而是显示:
Changes you made may not be saved.
Is overriding onbeforeunload message is still supported on our browsers? 我们的浏览器是否仍支持覆盖onbeforeunload消息? Because this issue is same with
Mozilla Firefox version 47.0.1
. 因为此问题与
Mozilla Firefox version 47.0.1
。
Or, am I doing it wrong? 或者,我做错了吗?
Chrome from Version 51 onwards no longer supports custom messages on beforeunload. 从版本51开始的Chrome不再支持在卸载前的自定义消息。
A window's onbeforeunload property may be set to a function that returns a string that is shown to the user in a dialog box to confirm that the user wants to navigate away. 窗口的onbeforeunload属性可以设置为一个函数,该函数返回在对话框中显示给用户的字符串,以确认用户要离开。 This was intended to prevent users from losing data during navigation.
目的是防止用户在导航期间丢失数据。 Unfortunately, it is often used to scam users.
不幸的是,它经常被用来欺骗用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.