火狐 Iframe 问题
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();
任何人都可以帮助我。
FireFox Shows Pop up for open or Save Dialog.
<iframe id="appFrame" runat="server" style="height: 95%; width: 100%; border: 0px;
z-index: -123;"></iframe>
I am using iframe to display word document,
document.getElementById("ctl00_GridContentPlaceHolder_appFrame").src = "ResponseWriter.aspx?docid=" + docId + "&doctype=" + docType + "&type=" + type;
I am calling ResponseWriter.aspx to write bytes it works well in IE but not in Firefox,Here is the code of 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();
Can any one please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是因为 Office 在 IE 中安装了一些钩子以支持“在浏览器中”查看 Office 文档,而 Firefox、Chrome 等只是将字节发送到 Office 应用程序。
如果没有看到“ResponseWriter.aspx”将字节发送到流的方式以及您在 Firefox 中看到的行为的更多详细信息,目前我无法猜测更多。
值得注意的是,您可能应该考虑使用 请求处理程序 (.ashx) 而不是 .aspx 页面 - 这对于此类请求有一个更清晰的模型,因为它不使用大部分页面生命周期。
This is probably because Office has installed some hooks into IE to support "in browser" viewing of Office documents, while Firefox, Chrome, etc. just send the bytes to the Office application.
Without seeing more details of the way "ResponseWriter.aspx" is sending the bytes to the stream and what behaviour you're seeing in Firefox, there's not much more I can guess at the moment.
As a point of note, you should probably look into using a request handler (.ashx) instead of the .aspx page - this has a cleaner model for these sorts of requests as it doesn't use most of the page life-cycle.