Whats the point of `beforeunload` returnValue if the message does not get set?

谁说胖子不能爱 提交于 2020-08-10 05:00:19

问题


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 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.

Example of chrome dialog


回答1:


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.



来源:https://stackoverflow.com/questions/45088861/whats-the-point-of-beforeunload-returnvalue-if-the-message-does-not-get-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!