【发布时间】:2014-11-02 03:41:03
【问题描述】:
我有这个发送过滤器字段的 ajax 表单:
@using (Ajax.BeginForm(Model.Action, Model.Controller, new AjaxOptions() { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, OnBegin = "onBegin", OnSuccess = "onSuccess", OnComplete = "onComplete" }, new { id = "formTemplate" }))
当我们提交这个表单时,它会返回一个局部视图:
//部分视图返回
@model PDFModel
<iframe id="rptIframe" frameborder="0" src="@Url.Action(Model.Action, Model.Controller, new { someItemID= Model.SomeItemID, someItemID2= Model.SomeItemID2 })#zoom=70"></iframe>
//
这是我的 onSucess 事件:
function onSuccess(result)
{
$("#rptContainer").html(result);
}
当我将它插入到 html 页面时,它会从 iframe 的 src 中触发 Url.Action... 此操作以 PDF 格式返回水晶报表,在表单下方呈现,这在 Chrome 中完美运行。
我的问题是我在请求工作时正在运行加载 gif,我使用 iframe 中的 onload 事件将其隐藏,但在 IE 中未触发 onload 事件,我该如何解决这个问题?。
我已经尝试过:
document.getElementById('frameRelatorio').setAttribute('onload', 'iframeLoad();');
和
var iframe = document.getElementById('frameRelatorio');
if (iframe.attachEvent) {
iframe.attachEvent('onload', iframeLoad);
}
else {
iframe.onload = iframeLoad;
}
和
onload="return someFunction();" //at the iframe
以及许多其他解决方案。
【问题讨论】:
标签: c# javascript ajax asp.net-mvc-4 iframe