Firefox - 设置Blob下载源

时间:2017-08-21 08:31:05

标签: javascript firefox blob

我正在创建一个脚本,允许您在页面上下载当前表格的CSV文件,如下所示:

var downloadLink = document.createElement("a");
var blob = new Blob(["", CSVString], {type: 'text/csv;charset=utf-8'});

if (navigator.appVersion.toString().indexOf('.NET') > 0) {
    window.navigator.msSaveOrOpenBlob(blob, "Daten.csv");
} 
else {
    downloadLink.href = window.URL.createObjectURL(blob);
    downloadLink.download = "Daten.csv";
    downloadLink.style.display = 'none';
    document.body.appendChild(downloadLink);

    downloadLink.click();
}

现在,如果我使用IE,它会询问我是否要从localhost下载文件,但在Mozilla Firefox中,下载窗口显示“From:blob:”。可以更改为显示我指定的主机名或名称(例如测试)吗?

1 个答案:

答案 0 :(得分:3)

可怜的是,到目前为止还没有可用的解决方案。 The issue was reported a couple of years ago but it seems it has the minor importance level and no one is asigned to this issue

From标签将始终显示from: blob:

enter image description here

无论你做什么。