0

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

enter image description here

window.addEventListener("beforeunload", (ev) => {  
 ev.preventDefault();
 return ev.returnValue = 'Are you sure you want to close?'; 
});
Sarthak Raval
  • 1,001
  • 1
  • 10
  • 23
Mohan
  • 375
  • 1
  • 9

1 Answers1

1

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

Greg
  • 5,862
  • 1
  • 25
  • 52