title: JavaScript OnChange Listener position in HTML markup
body: <p>I am having problems getting the OnChnage Listener to work, if i position the script after the <code>&lt;/form&gt;</code> tag the listener works fine but if i place the script within the <code>&lt;head&gt;</code> tags it fails to work. </p>
  
  <p>On my site i can only have the script within the <code>&lt;head&gt;</code> tags is there anything I can do to make the script runn within the <code>&lt;head&gt;</code> tags? </p>
  
  <p>in this configuration the script does not work</p>
  
  <pre><code>&lt;head&gt;
  &lt;script type="text/javascript"&gt;
  if(window.addEventListener) {
      document.getElementById('address').addEventListener('change', loadXMLDoc, false);
  } else if (window.attachEvent){
      document.getElementById('address').attachEvent("onchange", loadXMLDoc);
  }
  
  function loadXMLDoc(){
     alert('worked');
  }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form&gt;
  
  &lt;input id="address" name="address" type="text"/&gt;
  &lt;input id="test" name="test" type="text"/&gt;
  
   &lt;/form&gt;
  </code></pre>