如果未设置消息,`beforeunload` returnValue有什么意义? [英] Whats the point of `beforeunload` returnValue if the message does not get set?

查看:243
本文介绍了如果未设置消息,`beforeunload` returnValue有什么意义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL; DR没有现代的浏览器使用该消息.

您可以在此消息中滥用api,以便浏览器删除该参数的使用.感谢Huangism,lilezek和James的以下回复.

如果消息从未设置,则在onbeforeunload回调中设置事件returnValue有什么意义?

What is the point of setting the event returnValue in the onbeforeunload callback if the message never gets set?

此处的MDN文档建议我们设置此值,并且不设置此值就无法提示用户.但是,在设置该值时,我在任何确认消息中都看不到我的字符串.

The MDN docs here recommend that we set this value, and I'm not able to prompt the user without setting this value. However when setting that value I don't see my string in any of the confirmation messages.

Chrome对话框的示例

推荐答案

根据 MDN文档:

在某些浏览器中,事件的返回值显示在此对话框中.

In some browsers, the return value of the event is displayed in this dialog.

此外,在MDN文档的末尾,有一个表显示了每个浏览器删除的对自定义文本的支持.

Also, at the end of the MDN documentation, there is a table that shows every browser removed support of custom text.

这篇关于如果未设置消息,`beforeunload` returnValue有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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