📜  js appendchild 等待回调 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:14.752000             🧑  作者: Mango

代码示例1
function injectScript(src,callback){
    var script = document.createElement('script');
        script.src = src;
        script.onload=function(){
            callback();
        }
        document.head.appendChild(script);
}
injectScript('https://www.mysite.com/somescript.js', function(){
    //the script is now all loaded
});