title: Avoid the page scrolling/jumping when anchor is in the URL
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3659072/jquery-disable-anchor-jump-when-loading-a-page">jquery - disable anchor “jump” when loading a page</a>  </p>
  </blockquote>
  
  
  
  <p>I'm displaying a div depending on the hash value in a URL but i want to avoid the page jumping to the postion of that div with that particular ID. </p>
  
  <p>I only have the problem when the page is navigated direct with the hash in the URL so say for example if someone has book marked the page.</p>
  
  <p>So for example I have the url
  domain.com/page.html#myitem-1</p>
  
  <p>ID=myitem-1 will then display, which it does but the page then jumps down to the postion of that div which i don't want.</p>
  
  <p>I was trying to use scrollTop(0) to force the window position back to the top but it seems as if this gets called before the anchor jump takes place to has no effect</p>
  
  <p>Example code:</p>
  
  <pre><code>  $(document).ready(function() {
      $('.glossary-term').hide();
      $(window.location.hash).show();
  
      $(window).scrollTop(0);
  
  });
  </code></pre>
  
  <p>The only way i was able to get this scrollTop to work was to place it in a setTimeOut with a  duration of 1, but this seems like a bit of a hack.  Any other suggestions?</p>
  
  <p>Thanks</p>
  
  <p>B</p>