「JavaScript入門」scriptタグを動的に実行する方法
サンプルコード
//IEの場合
var script = document.createElement(“script");
script.setAttribute(“type","text/javascript");
script.onreadystatechange = function() {
if(this.readyState == “loaded" || this.readyState == “complete"){
console.log(“load success");
}
}
script.setAttribute(“src",scripts[i]);
//Opera、FF、Chromeの場合
var script = document.createElement(“script");
script.setAttribute(“type","text/javascript");
script.onload = function() {
console.log(“load success");
}
script.setAttribute(“src",scripts[i]);