title: Object #<HTMLDocument> has no method 'getElementByName'
body: <p>I copy some javascript example form jsfiddle and run them on local server but it shows the error on google chrome at inspect_element/console. Any suggestions for fixing this? Thanks.</p>
  
  <p>error:</p>
  
  <pre><code>Uncaught TypeError: Object #&lt;HTMLDocument&gt; has no method 'getElementByName'
  compute onclick
  </code></pre>
  
  <p>my code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;My fruit&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
      function checkFruit(){
          var fruit_radio_pointers = document.getElementsByName("fruit");
          var which_fruit = null;
          for(var i=0; i&lt;fruit_radio_pointers.length; i++){
              if(fruit_radio_pointers[i].checked){
                  which_fruit = fruit_radio_pointers[i].value;  
                  break;            
              }    
          }
          alert(which_fruit);
      }
  
      document.getElementById("my_btn").addEventListener("click", checkFruit, false);
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt;
      &lt;button id="my_btn"&gt;Which Fruit?&lt;/button&gt;
  &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>