动态加载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);
}

留下评论

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

85 + = 88