var _script = document.createElement("script");
_script.onload = _script.onreadystatechange = function(){
if(!this.readyState || this.readyState=='loaded' || this.readyState=='complete'){
_func(true);
_script.onload = _script.onreadystatechange = null;
}else{
_func(false);
}
};
document.getElementsByTagName("head")[0].appendChild(_script);
function _func(F){
if (F){
//do something
}else{
alert("网络异常!");
}
}
script.src = "https://www.jd.com/index.html";//这个网址被屏蔽了,无法访问
--------
为什么总是能调用到 _func(true);