一旦这行代码完成在IE8 $(this.frame).unbind('load')中执行.load(function() - > IE8中的状态栏显示加载由于某种原因而继续执行很长一段时间,并尝试使用IE Web开发人员进行调试无论如何都没有受益。是否有任何已知问题的jquery + iframe和IE8,我需要注意并导致此问题?
buildForm: function(fList, fOpts) {
if (!(this.getLocalURL())) return false;
var iDoc = (this.frame.contentWindow) ? this.frame.contentWindow.document : (this.frame.contentDocument.document) ? this.frame.contentDocument.document : this.frame.contentDocument;
var newForm = iDoc.createElement('form');
var method = 'POST';
var postUrl = fOpts.serviceURL+'&callbackUrl='+this.startURL;
newForm.setAttribute('action',postUrl);
newForm.setAttribute('method', method);
$(newForm).append("<input name='userDetail' type='hidden' value='"+JSON.stringify(fList)+"' />");
$(newForm).append('<input name="callbackUrl" type="hidden" value="'+this.startURL+'" />');
newForm = iDoc.body.appendChild(newForm);
this.isWaiting = true;
$(this.frame).unbind('load').load(function(){
Port.formControl.call(Port, this, fOpts);
});
newForm.submit();
},
formControl: function(formEl, fOpts) {
var url;
if (!(url = this.getLocalURL())) return false;
if (this.isWaiting === true) {
var resJSON = {};
var message = url.search.substring(1);
message = window.decodeURIComponent(message).split('&');
var i = message.length;
while (i-- > 0) {
var v = message[i].split('=');
if (v[1].charAt(0) == "{") v[1] = $.parseJSON(v[1]);
resJSON[v[0]] = v[1];
}
if (fOpts && fOpts.finishCallback instanceof Function) {
fOpts.finishCallback(resJSON);
}
}
}
答案 0 :(得分:0)
在buildForm的函数调用周围添加了setTimeout逻辑。我认为这允许创建iframe,在使用成功的配置文件更新消息对UI进行更新之前进行跨域访问。
$.fn[pluginName].post = function(argObj) {
Port.init(function(){
setTimeout(function() {
Port.buildForm(argObj.JSON, {
serviceURL: argObj.service,
finishCallback: argObj.callback
});
}, 10);
});
};