解決方法,用以下方法加載js:
. 代碼如下:
var loadScript = function(url, callback, charset){
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
if(charset){
script.charset = charset;
}
script.src = url;
if(!callback){
return;
}
script.onload = script.onreadystatechange = function(){
if(!this.readyState || this.readyState==='loaded' || this.readyState==='complete'){
callback();
}
};
head.appendChild(script);
};