 <p>Use event <a href="https://developer.mozilla.org/en-US/docs/DOM/window.onbeforeunload" rel="nofollow noreferrer">window.onbeforeunload</a>, which fires when the page is unloaded and return string <em>"You have pending unsaved changes. Do you really want to discard them?"</em></p> <p>Browser shows native dialog:</p> <p><img src="https://i.stack.imgur.com/kVQiv.png" alt="enter image description here"></p> <p>This is AFAIK the only way to stop navigation.</p> <p>jsFiddle: <a href="http://jsfiddle.net/phusick/R6EJ3/show/light/" rel="nofollow noreferrer">http://jsfiddle.net/phusick/R6EJ3/show/light/</a></p>