title: Cannot use document.getElementById() in global scope
body: <p>When I try this on the global scope:</p>
  
  <pre><code>document.getElementById("p1").innerHTML ="Howdy mate";
  </code></pre>
  
  <p>It does not work and firebug reports the error:</p>
  
  <pre><code>TypeError: document.getElementById is null
  </code></pre>
  
  <p>But the same instruction works well when inside a function:</p>
  
  <pre><code>function sayHello(){
      document.getElementById("p1").innerHTML ="Howdy mate";
  }
  </code></pre>
  
  <p>I am yet to find any literature to explain this behaviour. Can anyone help? </p>
  
  <p>EDIT: @All, the correct error message was</p>
  
  <p><code>document.getElementById("p1") is null</code>
  not </p>
  
  <p><code>Window.getElementById("p1") is not a function</code> </p>
  
  <p>as earlier stated. I have corrected. </p>