You should write the code like below. var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'something.js'; document.getElementById('div1').appendChild(script);
[EMAIL PROTECTED] wrote: > I have an issue that I initially thought was a jQuery problem, but > after simplifying things in preparation for posting my question, I see > that it's a fundamental javascript matter. > I don't understand why this works: http://pastebin.com/m3a767745 > but this doesn't: http://pastebin.com/m346451b4 > Note that the "external.js" file is just a single alert statement. > > What I'm trying to do (with javascript) is create a <script> element, > place it inside a particular element and execute it. > Thanks, > -Rob >