×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

水平太洼,没试成功。去网上找了一圈,你试试看吧:

用ASP实现的:
http://rtfm.atrax.co.uk/infinitemonkeys/articles/asp/934.asp

改客户端配置实现的:
You can't force a behaviour from a link using client-side JavaScript.

The only ways to prevent IE from actually loading the Word document via
OLE if Word is installed are:

1) visit every single machine you want to prevent the behaviour on and
break the MIME type connection on that copy of Windows
2) use some sort of server-side technology to send the following headers:

Content-Disposition: attachment; filename="thefile.doc"
Content-type: application/msword

then read and write the contents of the file to the browser.
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 紧急请教! 一般在网页中做一个链接,比如链接内容为WORD文件,在98系统中左键点击会直接打开,但是我想左键点击时出现下载界面,而不希望直接打开,不知如何才能实现?
    • 你试试在鼠标左键事件中,调用缺省右键操作。
      • 怎样调呢?如果这样行的话就太好了.多谢!
        • 水平太洼,没试成功。去网上找了一圈,你试试看吧:
          用ASP实现的:
          http://rtfm.atrax.co.uk/infinitemonkeys/articles/asp/934.asp

          改客户端配置实现的:
          You can't force a behaviour from a link using client-side JavaScript.

          The only ways to prevent IE from actually loading the Word document via
          OLE if Word is installed are:

          1) visit every single machine you want to prevent the behaviour on and
          break the MIME type connection on that copy of Windows
          2) use some sort of server-side technology to send the following headers:

          Content-Disposition: attachment; filename="thefile.doc"
          Content-type: application/msword

          then read and write the contents of the file to the browser.
    • 把word文件打包,让用户下载zip文件
    • 多谢bingle和gangs! 总结一下这几天所作的尝试
      本文发表在 rolia.net 枫下论坛总结一下实现下载的几种方案:

      1. 根据另一个论坛的一位朋友所提供的http://www.csdn.net/Develop/read_article.asp?id=13004
      一文结尾的一句,我在IIS4.0中对所要下载的文件作了如下设置:

      在HTTP Headers Tab中的Custom HTTP Headers一栏,加入:Content-Disposition: attachment; filename = "test1.mpg".

      这样设置以后,所有对test1.mpg的链接的点击马上就弹出下载对话框! 甚至都不用设置Content-Type

      但这样做的缺点是必须对每一个文件做设置,而且必须对服务器有访问权

      2. 上文还讲了用JSP和DLL+ASP实现的方法,应该都可行.但我对JSP一窍不通,而且IIS也不支持JSP吧?DLL对我也有难度.

      但bingle所提供的网址上,只用ASP就能实现.
      网址: http://rtfm.atrax.co.uk/infinitemonkeys/articles/asp/934.asp

      其中的Javascript和VBscript的版本我都试了,都好用.但问题有两个:

      1) 如其中所讲,可能要将服务器的MDAC升级后才能用'ADODB.Stream', 我就遇到了这个问题
      2) 同样的代码在IE6.0中连接时完全好用,但在IE5.5 SP1中连接时就让下载html文件本身,不知是为什么?

      3. 有位朋友建议用fireevent()来实现左键调右键,我查了一下,fireevent好像是用于调用自定义事件用的,不知怎样调用标准事件的缺省响应程序呢?

      4. gangs建议将doc, mpg等文件压缩后让用户下载zip文件.这的确可行,因为IE不认识zip文件,我以前也这么干过. 其实把文件随便改一个扩展名,象exe或xyz之类的也行,但毕竟给用户带来了不便,尤其是不太熟悉计算机的用户.

      多谢大家的帮助与启发更多精彩文章及讨论,请光临枫下论坛 rolia.net