octet stream download as csv doesn't work in IE

时间:2016-09-01 06:12:09

标签: javascript angularjs

I am trying to download an octet stream (basically JavaScript string) as CSV in my app using the following code:

//first getting the csv string from service
var csv = csvService.csv;

var hiddenElement = document.createElement('a');
hiddenElement.href = $window.URL.createObjectURL(new Blob([csv], {
  type: "attachment/csv"
}));;
hiddenElement.target = '_blank';
hiddenElement.download = 'myFile.csv';
hiddenElement.click();

This is working fine in Chrome and Firefox, but not in Internet Explorer (tried with 11). The file just doesn't get downloaded. What's the way to make it (or some other method) work in IE to download file? Really stuck with this.

0 个答案:

没有答案