title: javascript code not work in HEAD tag
body: <p>My webpage has the following code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;This is test Page&lt;/title&gt;
  
       &lt;script language="javascript" type="text/javascript"&gt;
  
           document.getElementById("msg1").innerHTML = document.URL.toString();
          &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;div class="sss"&gt;
          &lt;p id="msg1"&gt;&lt;/p&gt;
      &lt;/div&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>As you now at the time the script executes the div doesn't exist but I want to put my JavaScript code only In the <code>&lt;head&gt;</code> tag and I won't put it in middle of HTML code.</p>
  
  <p>But this code only works when I put the <code>&lt;script&gt;</code> tag after the <code>&lt;div&gt;</code> tag. 
  I use VS2010 and firefox 19.0.1 </p>
  
  <p>Is there anyway to put code in <code>&lt;head&gt;</code> tag?</p>