javascript onbeforeunload 不显示自定义消息
我有 onbeforeunload 事件的自定义消息并且运行良好,但我今天注意到它不再显示我的消息.而是显示您所做的更改可能无法保存"
I have custom message to onbeforeunload event and was working well but I noticed today that it's not showing my message anymore. Instead it shows "changes you made may not be saved"
window.onbeforeunload = function () {
return 'Custom message'
}
谁能告诉我如何解决它?
can anyone please let me know how to fix it?
为了避免欺诈,Chrome 和 Chrome 决定移除在 onbeforeunload
对话框中设置自定义消息的功能.
To avoid scamming, chromium and hence chrome have decided to remove the ability to set a custom message in the onbeforeunload
dialog.
请参阅 2016 年 2 月 18 日的错误报告.
See this bug report from the 18th of February, 2016.
onbeforeunload 对话框用于现代 Web 上的两件事:
1. 防止用户不慎丢失数据.
2. 诈骗用户.
onbeforeunload dialogs are used for two things on the Modern Web:
1. Preventing users from inadvertently losing data.
2. Scamming users.
为了在不阻止前者的同时限制它们对后者的使用,我们将不显示网页提供的字符串.相反,我们将使用通用字符串.
In an attempt to restrict their use for the latter while not stopping the former, we are going to not display the string provided by the webpage. Instead, we are going to use a generic string.
Firefox 已经这样做了[...]
Firefox already does this[...]