title: Problems with javascript scope in firefox
body: <pre><code>&lt;div id="myElement2"&gt;&lt;/div&gt;
  
  &lt;script&gt;
  window.onload = function() {
      document.getElementById("myElement1").onclick = function() {
          for (i = 0; i &lt; 2; i++) {
              document.getElementById("myElement2").onmouseover = func;
              function func() {alert("hello"); } } } }
  &lt;/script&gt;
  </code></pre>
  
  <p>In chrome and IE, when myElement1 is clicked, func is attached perfectly to myElement2.
  However, in firefox when myElement1 is clicked I receive an error message stating that func is not defined.</p>
  
  <p>I should note that if make an anonymous function instead of func then it works in all 3 browsers.</p>
  
  <p>My question is how does firefox handle scope in this regard differently to IE and chrome?</p>
  
  <p>Will.</p>