title: Detect if a new page is being loaded
body: <p>Is there a way to detect via JavaScript, whether a new page is being loaded. Let me give you an example.</p>
  
  <p>Another page is being loaded after I on this link:</p>
  
  <pre><code>&lt;a href='http://google.com/'&gt;Click here&lt;/a&gt;
  </code></pre>
  
  <p>There's no page load after I click here:</p>
  
  <pre><code>&lt;a href='#anchor'&gt;Click here&lt;/a&gt;
  </code></pre>
  
  <p>No page load here either:</p>
  
  <pre><code>&lt;a href='javascript:void(0);'&gt;Click here&lt;/a&gt;
  </code></pre>
  
  <p>Yep, that's a page load. But the <code>href</code> attribute is not URL of the page being loaded:</p>
  
  <pre><code>&lt;a href='javascript:void(document.location="http://google.com/");'&gt;Click here&lt;/a&gt;
  </code></pre>
  
  <p>This has URL in href, but it will not load a page. The <code>onclick</code> attribute is here just to illustrate the problem. In real world, the onclick event would probably by attached by event listener and canceled by <code>event.preventDefault()</code> somewhere else in the code:</p>
  
  <pre><code>&lt;a href='http://google.com/' onclick='return false;'&gt;Click here&lt;/a&gt;
  </code></pre>
  
  <p>Now imagine, that the next page takes long time to load. What I need is a way to detect whether a new page is being loaded, after I click on the link. Or after a form submit. Or after any action that can result in page load. I know which actions to watch, but I can't be sure if they necessarily trigger the page load.</p>
  
  <p>Is it even possible? If so, how?</p>
  
  <p>Thanks.</p>