javascript onbeforeunload不显示自定义消息 [英] javascript onbeforeunload not showing custom message

查看:756
本文介绍了javascript onbeforeunload不显示自定义消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有onbeforeunload事件的自定义消息,并且运行良好,但我今天注意到它不再显示我的消息。相反,它显示您所做的更改可能无法保存。

  window.onbeforeunload = function(){

return'Custom message'
}

任何人都可以让我知道如何解决为了避免被骗,铬和铬因此决定取消在<$ $中设置自定义消息的能力。 c $ c> onbeforeunload 对话框。



请参阅错误报告


onbeforeunload对话框用于现代网络上的两件事:

1.防止用户无意中丢失数据。

2.欺骗用户。



为了在不停止前者的情况下限制后者的使用,我们将不显示网页提供的字符串。相反,我们将使用一个通用字符串。



Firefox已经执行了这个[...]



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?

解决方案

To avoid scamming, chromium and hence chrome have decided to remove the ability to set a custom message in the onbeforeunload dialog.

See this bug report from the 18th of February, 2016.

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 already does this[...]

这篇关于javascript onbeforeunload不显示自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆