How can i show confirmation box before page reload?

In some cases before page refresh/reload we have to show confirmation message to the user. The page reload only if the user allow. In JavaScript we can use 'onbeforeunload ' function for this case.

I have checked the below code in latest Chrome & Firefox.

window.onbeforeunload = function(event)
    return confirm("Confirm refresh");
Final code and demo is here


No comments:

Post a Comment