title: JavaScript - Jump to anchor
body: <p>I'm trying to open a div with a jump to the anchor. The opening part is working but it's not jumping to the named anchor</p>
  
  <p>This is my script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function spoil(id){
          if (document.getElementById) {
              var divid = document.getElementById(id);
              divid.style.display = (divid.style.display = 'block');
              window.location = '#' + id;
          }
      }
  &lt;/script&gt;
  
  &lt;a href="http://example.com" onclick="spoil('thanks');" title="hello"&gt;
      &lt;img src="images/gfx.png" alt="world" width="300" height="300"/&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>Any ideas what's wrong with it?
  Cheers.</p>