problem including javascript dynamically
<p>I'm relatively new to Javascript and I am trying to write this short piece of code, found, by the way, as example on many web sites, but it doesn't work:</p>

<pre><code>var x = document.createElement("script");
x.type="text/javascript";
    x.src="GTV.js";
alert(x.textContent);
document.body.appendChild(x);
</code></pre>

<p>I don't get any error message, but the alert function returns blank, and the appendChild does not append anything. The GTV.js file is a local file on the same directory as the HTML. I know that I can include the js file in other more simple ways, but this is just an intermediate step to load, instead of GTV.js, another page from another site.
Where am I wrong? BTW, I'm using Firefox 4.0 Beta, but the same happens with IE8
Thanks</p>

<p><strong>Update</strong></p>

<p>Thanks for the answers.</p>

<p>In order: 1) Tom: I'm just trying to include a script at runtime - should be easy, I've seen lots of examples ... just isn't working for me and don't understand what's wrong 2) Xs10tial: I don't have the slightest idea what you are talking of - sorry, it's certainly my lack of experience 3) Atanas: I tried your suggestion but it doesn't work. By the way, looking at your example, should I put my 2 lines of code within the if cycle (where you write "//The script is executed") at the end, where they currently are? 4) Jayantha: doesn't work. By the way, why are you referring to css rather than js?</p>

<p>Any other suggestion?</p>
