How To Show Prompt Message When Refreshing The Page
I work on Javascript and I have a simple page.I need to prompt message appear when user want to refresh the page(F5, so on). Is there any method to do so? I have tried to use meth
Solution 1:
You can use window.onbeforeunload
. The user will be prompted your message and he has the possibility to stay or to leave.
JavaScript
window.onbeforeunload = function(e) {
return"Don't leave";
};
Demo
Learn more on the MDN window.onbeforeunload
Post a Comment for "How To Show Prompt Message When Refreshing The Page"