Reputation: 385
I'm trying to add this custom message using the below code but it's showing the default message. please help me where I'm doing wrong thanks in advance
window.addEventListener("beforeunload", (ev) => {
ev.preventDefault();
return ev.returnValue = 'Are you sure you want to close?';
});
Upvotes: 0
Views: 1217
Reputation: 6628
This dialog looks like chrome, and chrome removed the option to customize this message, see here: https://developers.google.com/web/updates/2016/04/chrome-51-deprecations?hl=en#remove_custom_messages_in_onbeforeunload_dialogs
Also this answer claims it's not only chrome, but most browsers https://stackoverflow.com/a/38880926/299774
Upvotes: 1