I'm working under ASP.NET and I wonder if is possible to display a custom save prompt (let's say a div
with styles, a message and some buttons) when the user is trying to leave the page.
I've seen the onunload
and onbeforeunload
JS events.
The onunload
event seems to does not work for my purpose, because I display the message but I can't prevent the user from leaving the page.
The onbeforunload
could be useful just because I can prevent the user from leaving the page, but the prompt is the responsibility of the navigator, and I want to implement it!
I think there is not another option than onbeforeunload
to warn the user about possible losses of work but I expect helpful answers.
Related question: Prompting user to save when they leave a page