javascript - Firefox Iframe 问题

标签 javascript asp.net firefox cross-browser

FireFox 显示用于打开或保存对话框的弹出窗口。

<iframe id="appFrame" runat="server" style="height: 95%; width: 100%; border: 0px;
                    z-index: -123;"></iframe>

我正在使用iframe显示word文档,

document.getElementById("ctl00_GridContentPlaceHolder_appFrame").src = "ResponseWriter.aspx?docid=" + docId + "&doctype=" + docType + "&type=" + type;

我正在调用 ResponseWriter.aspx 写入字节,它在 IE 中运行良好但在 Firefox 中运行良好,这是 ResponseWriter.aspx 的代码

        Response.ClearHeaders();
        Response.ClearContent();
        Response.AddHeader("MIME Type", type.Trim()); 
        Response.AppendHeader("content-disposition",
                "inline;attachment; filename=" + "Unknown." + docType);

        Response.AddHeader("Content-Length", _fileArray.Length.ToString());
        Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
        Response.ContentType = type.Trim();
        Response.BinaryWrite(_fileArray.ToArray());
        Response.End();

谁能帮帮我。

最佳答案

这可能是因为 Office 在 IE 中安装了一些钩子(Hook)以支持“在浏览器中”查看 Office 文档,而 Firefox、Chrome 等只是将字节发送到 Office 应用程序。

没有看到“ResponseWriter.aspx”将字节发送到流的方式的更多细节以及您在 Firefox 中看到的行为,目前我无法猜测更多。

请注意,您可能应该考虑使用 request handler (.ashx)而不是 .aspx 页面 - 对于这些类型的请求,它有一个更清晰的模型,因为它不使用大部分页面生命周期。

关于javascript - Firefox Iframe 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6097181/

相关文章:

javascript - 在 Meteor 中的 Iron Router 模板助手上使用参数

c# - 通过信号器从部分 View 发送消息

c# - ASP.Net 请求生命周期 - Application_BeginRequest

javascript - 为什么简单的 Promise 语句在浏览器中不起作用

Firebase 推送通知在 Firefox 63 中不起作用

javascript - 如何使用 JavaScript 添加 HTML 代码到调用函数的对象?

javascript - 在 Cookie(或可能的 session 存储)中存储按钮切换状态的最佳方式?

javascript - vue.js v 类绑定(bind)覆盖了其他绑定(bind)并且没有正确删除类

c# - 无法在网站项目中找到 System.Net.Http

javascript - 如何检测意外鼠标操作导致的输入变化?