function loadScript(url,callback) {
var script = document.createElement("script");
script.type = "text/javascript";
if(script.readyState) {
script.onreadystatechange = function() {
if(script.readyState == "complete" || script.readyState == "loaded") {
callback();
}
}
}else {
window.onload = function() {
callback();
}
}
script.src = url;
document.head.appendChild(script);
}
loadScript("js/jquery.js",function() {
console.log(document.readyState);
})
javascript 异步加载js文件
最新推荐文章于 2023-07-16 12:13:17 发布