问题
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