Javascript appendchild not including element in Body/Head
<p>I am using code to add javascript to my page using javascript file..</p>

<p>My code is :</p>

<pre><code> alert("works");


   addScript('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
   addScript('js/pdttrack/jquery.titlealert.js');
   addScript('js/pdttrack/jquery.msgbox.min.js');

  function addScript(filename) {
      var tagPosition = document.getElementsByTagName('body');
      var scriptElement = document.createElement('script');
      scriptElement.setAttribute('type', 'text/javascript');
      scriptElement.setAttribute('src', filename);
      tagPosition.appendChild(scriptElement);
      alert("added "+ scriptElement);
  }
</code></pre>

<p>...but the last alert is not firing.. seems   </p>

<pre><code>tagPosition.appendChild(scriptElement);
</code></pre>

<p>is not firing rest all are..</p>
