代码之家  ›  专栏  ›  技术社区  ›  m.edmondson

提示下载

  •  3
  • m.edmondson  · 技术社区  · 14 年前

    提示用户下载东西的最佳方法是什么?过去我用过 window.open('file.pdf'); 但我可以看到弹出窗口拦截器对此有问题。当然我会包括一个手动链接。

    我基本上想要像 Microsoft Download page

    3 回复  |  直到 14 年前
        1
  •  3
  •   Joachim VR    14 年前

    使用javascript重定向。

    function redirect() {
    window.location = 'http://www.url.to/your.file';
    }
    
        2
  •  1
  •   Alin P.    14 年前
    Content-Disposition: attachment; filename="file.pdf"
    

    为此,您可能需要通过服务器脚本传递file.pdf文件,该脚本强制在文件头上传递该文件。

    你在下载页面上看到的只是位置的改变。如果该页面返回下载标题,浏览器将不会更改页面。

        3
  •  0
  •   Quentin    14 年前

    使用附件值设置内容处置头