javascript - Help required on onbeforeunload or click on browser back button -


if user clicks browser's button, want prompt appear , ask confirmation. if user clicks 'ok', should navigate xx.html. if user clicks 'cancel', should prevent navigation. how can this?

note: tried onbeforeunload method, working navigation actions. example, clicking link on page fire event , show message user.

you can't. best can use onbeforeunload , remove event when clicking on normal link:

<script type="text/javascript"> window.onbeforeunload = function() {return "are sure?"} </script>  <a href="somewhere.html" onclick="window.onbeforeunload = null;">leave</a> 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -