动态插入script

let script = document.createElement(“script”);
script.type = “text/javascript”;
if (typeof(callback) != “undefined”) {
if (script.readyState) {
script.onreadystatechange = function() {
if (script.readyState == “loaded” || script.readyState == “complete”) {
script.onreadystatechange = null;
callback();
}
};
} else {
script.onload = function() {
callback();
};
}
};
script.src = ‘XXXXXXXX.js’;
document.body.appendChild(script);

你可能感兴趣的:(javascript,javascript)