[javascript]代码库
//callback函数即onload功能
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);
}
loadScript('https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js', function(){alert('加载成功')});
by: 发表于:2018-05-29 09:43:54 顶(0) | 踩(0) 回复
??
回复评论