title: Firefox reloading parent page in iframe when clicking named anchor
body: <p>My site has an iframe which is dynamically populated with html content. The html often contains named anchors, which work fine in IE/Chrome but in Firefox it reopens the entire page within the iframe.</p>
  
  <p>Here's an example: load the page in firefox, scroll to the bottom of the iframe, click the "back to top" link, and you will see what I am talking about.</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body onload="setFrameContent();"&gt;&lt;script&gt;
  
  var htmlBody = '&lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt;' +
  '&lt;a name="top"&gt;&lt;h1&gt;top&lt;/h1&gt;&lt;/a&gt;' +
  '&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;' +
  '&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;' +
  '&lt;a href="#top"&gt;back to top&lt;/a&gt;&lt;/body&gt; &lt;/html&gt; ';
  
  function setFrameContent(){
      if (frames.length &gt; 0) {
          var d = frames[0].document;
          d.open();
          d.write(htmlBody);
          d.close();
      }
  }
  
  &lt;/script&gt;
  &lt;h1&gt;Here's an iframe:&lt;/h1&gt;
  &lt;iframe id="htmlIframe" style="height: 400px; width: 100%"&gt;&lt;p&gt;Your browser does not support iframes.&lt;/p&gt;&lt;/iframe&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Any ideas?</p>