title: How do I execute code before a hashchange?
body: <p>Basically, I want to construct a <code>beforehashchange</code> event. I want to execute code <em>before</em> the <code>hashchange</code> event affects the page (i.e.: scrolls to the target).</p>
  
  <p>The only things I know of that can change the hash (and cause a <code>hashchange</code> event) are:</p>
  
  <ul>
  <li>clicking <code>&lt;a href="#foo"&gt;</code>, in which case I could capture the <code>click</code> event, and check for a link to a hash.</li>
  <li>changing the hash in the URL bar manually, which I can probably ignore (unless someone knows a way to detect this before it triggers the <code>hashchange</code>?)</li>
  </ul>
  
  <p>Are there other ways to trigger a <code>hashchange</code>?</p>