DEV Community

Discussion on: Sure you want to leave?—browser beforeunload event

Collapse
 
karapapas profile image
karapapas

Hello! Great article on beforeunload.

I have a question though, is it possible to prevent page unload and stay on the page without prompting the user? Or, if that is not possible, to at least customize the confirmation dialog?

Thank you for your time!!

Collapse
 
samthor profile image
Sam Thorogood

No, that's the whole point. You could write something like "CLOSING THIS PAGE WILL EXPLODE YOUR COMPUTER", and browsers have decided that you should not be able to do that.