title: Setting location.hash in frames
body: <p>I am using ajax to update the location of a page in a frame. But when setting the location of the hash (on Chrome and some versions of IE (5.5) specifically, but occasionally on IE7) the page is being reloaded.</p>
  
  <p>The following html demonstrates the problem.</p>
  
  <p>the main frame....  frame.html is</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;
  &lt;frameset rows="*"&gt;
  &lt;frame src=sethash.html frameborder=0 scrolling=auto name=somebody&gt;
  &lt;/frameset&gt;
  &lt;/head&gt;&lt;/html&gt;
  </code></pre>
  
  <p>the sethash.html page is .</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;
  &lt;script language=JavaScript&gt;
  var Count = 0;
  function sethash()
  {  
    top.document.location.hash = "hash" + Count;  
    Count++;
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="alert('loaded')"&gt;
  &lt;h1&gt;Hello&lt;/h1&gt;
  &lt;input type='button' onClick='sethash()' value='Set Hash'&gt;
  &lt;/body&gt;
  &lt;/html&gt;`
  </code></pre>
  
  <p>On most browsers loading the frame.html will show the loaded alert once when the page is loaded. Then when the set hash button is pressed the url will be changed but the hash the loaded alert will not show again. On chrome and some versions of I.E</p>
  
  <p>Microsoft report possibly the same problem with Internet Explorer 5.5 <a href="http://support.microsoft.com/kb/274586" rel="nofollow noreferrer">link text</a></p>
  
  <p>I can't use the microsoft suggested solution, which is to capture the event and not fire it, but just scroll into view, as am using set the top.location.hash as part of the onLoad event.</p>