15/12/2021
[Read More]
Have you seen this dialog box in websites? This is how to implement it!
The before upload event is invoked when the user navigates away from the page, whether it is a reload, going backward, forward or a new URL.
We can simply call preventDefault on the event to indicate to the browser that the user has some pending changes to be saved.
⚠️ Chrome browser alone requires the return value to be set for the event, but the message is ignored though, so you can simply set an empty string.
In the future there is possibility for browser to implement custom warning messages, but for now it is just the predefined text.
Reposted from