【问题标题】:JavaScript script dynamic script loading IE6 issueJavaScript脚本动态脚本加载IE6问题
【发布时间】:2010-02-12 14:42:41
【问题描述】:
我正在使用内部自定义库来复制 jsonp 调用。在你们要求我使用 JQuery 或其他库之前,让我告诉我由于某些限制我不能使用它。
以下是用于发出请求的代码:
BurrpJsonAjaxRequest.prototype.send = function() {
this.script = document.createElement("script");
this.script.type = "文本/javascript";
this.script.charset = "UTF-8";
this.script.src = this.URL;
if (typeof(this.callBack) == "function") {
this.script.callback = this.callBack;
}
var currRequest = 这个;
//睡眠(100);
if (this.script.src.readyState) { //IE
this.script.src.onreadystatechange = function() {
if (this.script.src.readyState == "已加载" ||
this.script.src.readyState == "完成") {
this.script.src.onreadystatechange = null;
currRequest.hideLoading();
currRequest.callback();
}
};
} else { //其他
this.script.src.onload = function() {
currRequest.hideLoading();
currRequest.callback();
};
}
this.docHead.appendChild(this.script);
};
这在第一次执行时有效。在随后的执行中,发出请求但不执行回调。
如果我使用如下的睡眠方法(在代码中注释),回调也会在后续调用中执行。
功能睡眠(毫秒){
var start = new Date().getTime();
for (var i = 0; i 毫秒){
休息;
}
}
}
睡眠如何影响回调的执行?不过在 Firefox 中运行良好。
【问题讨论】:
标签:
javascript
internet-explorer-6
dynamic-script-loading