title: Javascript Quirk: accessing node without getElementByID
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3434278/ie-chrome-are-dom-tree-elements-global-variables-here">IE/Chrome: are DOM tree elements global variables here?</a><br>
    <a href="https://stackoverflow.com/questions/12663981/element-accessible-with-id">Element accessible with ID</a>  </p>
  </blockquote>
  
  
  
  <p>I didn't realise until recently that you can access a DOM element by it's ID without using document.getElementByID()</p>
  
  <pre><code>​&lt;div id="test"&gt;
    hi there
  &lt;/div&gt;​​​​​​​​​​​​​​​​​​​​​​​​​
  
  ​alert(test.textContent);​ //alerts "hi there"
  </code></pre>
  
  <p>What's weirder is that it is supported in FF, Chrome, Safari and IE9+</p>
  
  <p>The only problem I can see is if you overwrite the name ie) <code>var test=3;</code> and it would no longer work. But you have that same problem when setting <code>var test = document.getElementById('test');</code></p>
  
  <p>My questions are:</p>
  
  <p>-Why/how does this work... Is the browser accessing it through the window object?</p>
  
  <p>-Is it a bad practice?</p>
  
  <p>-Is it supported by older browsers (IE6)?</p>