最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Whats the point of `beforeunload` returnValue if the message does not get set? - Stack Overflow

programmeradmin3浏览0评论

TL;DR No modern browsers use the message.

You can abuse the api with this message so browsers dropped the use of the parameter. Thank you Huangism, lilezek, and James for the below responses.

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

The MDN docs here remend 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.

Example of chrome dialog

TL;DR No modern browsers use the message.

You can abuse the api with this message so browsers dropped the use of the parameter. Thank you Huangism, lilezek, and James for the below responses.

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

The MDN docs here remend 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.

Example of chrome dialog

Share Improve this question edited Nov 7, 2017 at 17:58 Emmett Harper asked Jul 13, 2017 at 18:52 Emmett HarperEmmett Harper 2594 silver badges16 bronze badges 2
  • 1 It used to work in older browsers but modern browsers now do not show the text anymore which I assume is to be more secure? – Huangism Commented Jul 13, 2017 at 18:55
  • It was removed because this technique was often used by disreputable sites to scam users. – James Commented Jul 13, 2017 at 19:11
Add a ment  | 

1 Answer 1

Reset to default 5

According to MDN docs:

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

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

发布评论

评论列表(0)

  1. 暂无评论