Javascript: Run "document.write" in createElement script failed
<p>I have a problem with "document.write". Now, I have a page to load script dynamic. So, i use "document.createElement" to create a . And int the script javascript file, I use "document.write" to create a dom or iframe element. But it dose not work in every browser. So, I want to konw, why? </p>

<p>Thx!</p>

<p>Code in homepage:</p>

<pre><code>var script = document.createElement('script');
script.setAttribute('src', 'http://yoururl/test.js');
document.getElementsByTagName('head')[0].appendChild(script);
</code></pre>

<p>Code in script test.js:</p>

<pre><code>(function(){document.write('hello');})();
</code></pre>
