var loadScript = function (url,cb) {
var script = document.createElement('script');
script.src = url;
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(script,firstScript);
// script 加载完毕后调用方法
script.onload = script.onreadystatechange = function(){
if( ! this.readyState //这是FF的判断语句,因为ff下没有readyState这个值,IE的readyState肯定有值
|| this.readyState=='loaded' || this.readyState=='complete' // 这是IE的判断语句
){
cb && cb()
}
};
}
网友评论