× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

JavaScript pause before leaving a web page

Adam Derewecki
Oct 15, 2014
<p>Ever need to investigate that state of your JavaScript just before the page unloads?</p><p>Let's imagine you have a form whose `submit` action has a callback that does validation. But the JavaScript is broken, and you see an error flicker across the console just before the form is submitted and you're taken to the next page. How can you see that error message for more than a split second?</p><p>Easy! Tell the window to drop to an interactive debugger before unloading:</p><pre><code class="language-javascript">window.onbeforeunload = function() { debugger; }</code></pre><p> </p>
comments powered by Disqus