Blob doesn't load in safari

I am trying to download a csv file, but it seems to work in all browsers except safari? how did it happen. in safari, it just shows it in the browser?

Here is my code:

var saveData = (function () { var a = document.createElement("a"); document.body.appendChild(a); a.style = "display: none"; return function (data, fileName) { var blob = new Blob([data], {type: "text/csv;charset=utf-8"}), url = window.URL.createObjectURL(blob); a.href = url; a.download = fileName; a.click(); setTimeout(function(){ window.URL.revokeObjectURL(url); }, 100); }; }()); 
+4
source share
1 answer

Using an HTML 5 upload attribute in an anchor tag that Safari does not support.

http://caniuse.com/#feat=download

Most likely, it’s best to link the file and set the headers as shown so that the agent downloads rather than displays.

Content-Type: text / csv Content-Disposition: attachment; file name = "whatever.csv"

+1
source

All Articles