【问题标题】:Firefox Iframe IssueFirefox iframe 问题
【发布时间】:2011-08-31 03:07:11
【问题描述】:

FireFox Shows 弹出打开或保存对话框。

<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();

谁能帮帮我。

【问题讨论】:

  • 您遇到了什么问题?你没说。您可以发布实际返回文件的代码吗?

标签: javascript asp.net firefox cross-browser


【解决方案1】:

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

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

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

【讨论】:

  • 明确一点——如果访问者没有用于呈现 Office 文档的浏览器插件,那么您无法让他们的浏览器呈现 Office 文档。
  • 我已经更新了我的问题,请您给我建议
  • Firefox 只是不会在浏览器中显示它们。我相信 content-disposition 标头实际上是 IE 团队实现了一些支持的电子邮件标头 - Firefox 并没有打扰它会出现。 stackoverflow.com/questions/1012437/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-10-16
  • 2015-12-25
  • 2013-03-19
  • 2011-11-28
  • 2013-12-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多