title: perform href before onClick
body: <p>I've the following link:</p>
  
  <pre><code>&lt;a href="#HDR" onClick="showGallery()"&gt;I&lt;/a&gt;
  </code></pre>
  
  <p>And this use the following javascript:</p>
  
  <pre><code>function showGallery(){
      if(window.location.hash) {
        $('#gallery').fadeIn('fast');
        var hash = window.location.hash.substring(1);
        alert(hash);
      } else {
  
      }
  
  }
  </code></pre>
  
  <p>So it only show the gallery when in the URL is a hashtag. But when i click on the link, nothing happens. When i click it twice, the gallery fade in. </p>
  
  <p>So the link first make the javascript, and i doesn't work 'cause there is no hashtag in the URL and after that, it perform the href and insert the Hashtag in the URL. 
  How can i do that?</p>
  
  <p>My Target:</p>
  
  <p>When i click on a link, it open a gallery. To know which gallery i must open, i insert in the URL a Hashtag. Here i want to display the HDR album. And i also want, if my site get opend with a hashtag, it should display the gallery.! </p>
  
  <p>Is there also a another, easier or cleaner way to make it?
  Hope you understand what i want.</p>