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); }; }());
source share