Detecting if browser navigating to another page
<p>I need to check if browser is navigating to another page or closing.
My idea is;</p>

<ol>
<li>Create global variable <code>var isNavigating = false;</code></li>
<li>Bind click event to make <code>isNavigating = true</code> of every anchor which will navigate to another page </li>
<li>Check if <code>isNavigating</code> true on body's <code>unload</code> event.</li>
</ol>

<p>Any other ideas? Recommendations?</p>
