我的应用程序的弹出窗口中有一个 ajax 样式的表单。我使用带有目标 iframe 的表单,然后在 iframe.load() 函数上,获取内容并将它们显示回我的弹出窗口。
这适用于 IE9、Chrome、Firefox:
$("iframe[name=addpart-iframe]").load(function () {
//FF and IE fire the load when the popup first load, chrome does not. This kips the first onload where no submit has happened yet
if (firstLoad == true) {
firstLoad = false;
return;
}
var response = this.contentDocument.body.innerHTML;
$("#AddForm").html(response);
});
这很好用,除了在 IE7 中。当我查看 this.contentDocument.body 时——调试器说 body 不是一个有效的属性。我看外面的html,我的iframe此时也是空的。不知道为什么!