动态加载JS

var loadJs = function(url, callback) {
var script = document.createElement(‘script’);
script.type = ‘text/javascript’;
if (callback)
script.onload = script.onreadystatechange = function() {
if (script.readyState && script.readyState != ‘loaded’ && script.readyState != ‘complete’) return;
script.onreadystatechange = script.onload = null;
//callback();
};
script.src = url;
document.getElementsByTagName(‘head’)[0].appendChild (script);
}



发表评论

电子邮件地址不会被公开。 必填项已用*标注

− 5 = 3