我现在把excel弹出保存框而不是在浏览器里打开

supertj 2002-03-05 04:20:35
我现在把excel文件做为链接,可是点击后直接在浏览器里打开了,有什么办法能弹出下载提示框吗???急.谢谢.我分不多,只能给20分啦.谢谢大家能帮我解答这个问题.
...全文
120 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
supertj 2002-03-05
  • 打赏
  • 举报
回复
首先谢谢你把这一大段信息贴上来,按理说我应该把分给你了, 不过我试了上面的方法, 它只是下载下来一个空的EXCEL文件, 没有把我服务器上的文件给传到客户端啊, 是不是我方法用错了, 麻烦你再点拨一下谢谢啦。
supertj 2002-03-05
  • 打赏
  • 举报
回复
首先谢谢你把这一大段信息贴上来,按理说我应该把分给你了, 不过我试了上面的方法, 它只是下载下来一个空的EXCEL文件, 没有把我服务器上的文件给传到客户端啊, 是不是我方法用错了, 麻烦你再点拨一下谢谢啦。
孟子E章 2002-03-05
  • 打赏
  • 举报
回复
怎样直接下载而不打开已知类型的文件

HOWTO: Raise a "File Download" Dialog Box for a Known MIME Type (Q260519)

--------------------------------------------------------------------------------
The information in this article applies to:


Microsoft Internet Explorer (Programming) versions 5 , 5.01 , 5.5


--------------------------------------------------------------------------------


SUMMARY
When you serve a document from a Web server, you might want to immediately prompt the user to save the file directly to the user's disk, without opening it in the browser. However, for known MIME (Multipurpose Internet Mail Extensions) types such as Microsoft Word ("application/ms-word"), the default behavior is to open the document in Internet Explorer.

You can use the content-disposition header to override this default behavior. Its format is:

Content-disposition: attachment; filename=fname.ext



MORE INFORMATION
Content-disposition is an extension to the MIME protocol that instructs a MIME user agent on how it should display an attached file. The range of valid values for content-disposition are discussed in Request for Comment (RFC) 1806 (see the "References" section of this article). This article focuses on the "attachment" argument, which instructs a user agent (in this case, Internet Explorer) to save a file to disk instead of saving it inline.

When Internet Explorer receives the header, it raises a File Download dialog box whose file name box is automatically populated with the file name that is specified in the header. (Note that this is by design; there is no way to use this feature to save a document to the user's computer without prompting him or her for a save location.)

There are two ways that you can use Internet Explorer to specify a content-disposition header for a file: dynamically and statically.

To apply the header dynamically, create an Active Server Pages (ASP) file that writes the document out to the browser. Use the Response.AddHeader method to add the content-disposition header. For example:

Response.AddHeader "content-disposition","attachment; filename=fname.ext"
Instructions on how to perform a binary write for nontext documents are available in the following Microsoft Knowledge Base article:
Q193998 HOWTO: Read and Display Binary Data in ASP
This technique is ideal when you want to protect a document store on your server, especially one that exists outside of the Web root.

To apply the header statically, right-click the document in the Internet Service Manager, and then select Properties . Select the HTTP Headers tab and enter the content-disposition header there. This works best when you only want to apply content-disposition to a few files on your system and don't require the overhead of ASP.

Please note that this solution will not work in Internet Explorer 4.01 due to a bug. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
Q182315 FIX: Content-Disposition: Does Not Force File Download Dialog



REFERENCES
Request for Comment 1806: Content-Disposition

For more information on developing Web-based solutions for Internet Explorer, please see the following Web sites:


http://support.microsoft.com/default.aspx?scid=http://msdn.microsoft.com/workshop/entry.asp

http://support.microsoft.com/default.aspx?scid=http://msdn.microsoft.com/ie/

http://support.microsoft.com/default.aspx?scid=http%3a%2f%2fsupport.microsoft.com%2fhighlights%2fiep.asp%3fFR%3d0%26amp%3bSD%3dMSDN

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧