2. Include the first JavaScript file with a script tag at the bottom of the page, just inside the .
3. Create a second script tag that calls the function to load the second JavaScript file and contains any additional initialization code.
function loadScript(url, callback){
var script = document.createElement("script")
script.type = "text/javascript";
if (script.readyState){ //IE
script.onreadystatechange = function(){
if (script.readyState == "loaded" ||
script.readyState == "complete"){
script.onreadystatechange = null;
callback();
}
};
}else{ //Others
script.onload = function(){
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
No comments:
Post a Comment