提示下载位置而不是直接下载 [英] Prompt a download location instead of downloading directly

查看:117
本文介绍了提示下载位置而不是直接下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JavaScript中创建一个CSV元素,然后模拟单击以下载相应的文件。

I am creating a CSV element in JavaScript and then simulating a click to download the respective file.

但是我没有直接下载而是希望它打开下载提示来选择要下载的文件的位置。

But instead of downloading directly i want it to open a download prompt to choose the location of file to be downloaded.

var csvString = Papa.unparse(result,{
                                quotes: false,
                                delimiter: ",",
                                newline: "\r\n"
                        });
var a         = document.createElement('a');
a.href        = 'data:attachment/csv,' + escape(csvString);
a.download    = "download.csv";
a.click();

如何做到这一点?

推荐答案

这是特定于浏览器的设置。

This is a browser specific setting.


  1. 在Chrome中:转到设置>下载> 然后选择复选框
    在下载之前询问每个文件的保存位置

  2. 在Firefox中:转到工具>选项,打开常规标签并选择单选按钮始终询问我在哪里保存文件

  3. 在Internet Explorer 8中:打开下载对话框时,单击保存按钮并选择位置。

  1. In Chrome: Go to Settings > Downloads > and then select checkbox Ask where to save each file before downloading
  2. In Firefox: Go to Tools > Options, open General tab and select radio button Always ask me where to save files
  3. In Internet Explorer 8: When the download dialog opens up, click Save button and choose the location.

这篇关于提示下载位置而不是直接下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆