Having one javascript load multiple other javascripts without touching the <head>
<p>I'm working for a company right now that has hundreds of pages that use a javascript to load a left sidebar. I didn't create the original, but have to work within its framework. I;m fairly new to Java, want to insert a new image slideshow (from <a href="http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm" rel="nofollow">http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm</a>) into the this sidebar. Unfortunately, I need to load 3 other javascript files in this one, as well as create a div with the javascript for my slideshow to go in. I spent 6 hours on it today, trying multiple solutions I've found on this site and others, couldn't get it to work. </p>

<p>Is this possible? </p>

<p>I need to load "javaA.js", "javaB.js", &amp; "javaC.js" from this script, which runs on over 500 pages. Part 2 is having a div created, but just this first part would help heaps.</p>

<p>Thanks in advance for help.</p>

<p>Solution Found:</p>

<p>Here's the code that ended up working for me:</p>

<pre><code>function loadjscssfile(filename, filetype){
if (filetype=="js"){ //if filename is a external JavaScript file
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)

if (typeof fileref!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileref)
}
loadjscssfile("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "js")
loadjscssfile("JavaA.js", "js")
loadjscssfile("JavaB.js", "js")
</code></pre>
