title: Using appendChild with IE in Javascript
body: <p>I am having trouble with this code in IE (with Chrome it seems to work fine):</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;
      var scriptContent = "var whatever=1";
      var _js = document.createElement('script');
      _js.setAttribute('type', 'text/javascript');
      textNode = document.createTextNode(scriptContent);
      _js.appendChild(textNode);  
      document.getElementsByTagName('body')[0].appendChild(_js);
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The error I get in Internet Explorer (IE9) is: "unexpected call to a method or access to a property" on statement "_js.appendChild(textNode)".</p>
  
  <p>Is there any way to work around this problem?</p>