Code Snippet posted by:
Poster | Posted on: 3/1/2009 | Category:
JavaScript Codes | Views: 4511 | Status:
[Member]
|
Alert Moderator
Lets say you have a .js file and you want another .js file to load from this .js file without addding another <script> tag to load .js file in every page of the website, you can use following function
function addJavascript(jsname) {
var th = document.getElementsByTagName('head')[0];
var s = document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src',jsname);
th.appendChild(s);
}
You can call above function like this
addJavascript('/yourjsfile.js');