2011-05-23 85 views
1

FireFox显示弹出打开或保存对话框。Firefox Iframe问题

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

任何人都可以帮助我。

+1

你有什么问题?你没有说。你能发布实际返回文件的代码吗? – Oded 2011-05-23 12:29:25

回答

2

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

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

作为一个需要注意的问题,您应该考虑使用request handler (.ashx)而不是.aspx页面 - 这种类型的请求具有更清晰的模型,因为它不使用大部分页面生命周期。

+3

只是要明确 - 如果访问者没有用于呈现Office文档的浏览器插件,则无法使其浏览器呈现Office文档。 – Quentin 2011-05-23 13:10:57

+0

我已更新我的问题,您能否给我建议 – Ramakrishnan 2011-05-25 08:01:29

+0

Firefox只是不会在浏览器中显示它们。我相信内容处置标题实际上是一个电子邮件标题,IE团队实施了一些支持 - Firefox并没有打扰它会出现。 http://stackoverflow.com/questions/1012437/uses-of-content-disposition-in-an-http-response-header – 2011-05-25 08:20:24