JSFiddle - React, Tailwind, and code Playground
by jhorvath
HTML
<div>TODO: Base64 input?</div>
JavaScript
var csvString = "\"A1-Left,A1-Right\",\"B1-Left,B1-Right\",C1,D1";
var fileName = "UmkreisFinderResult-5km.csv";
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
try {
var blob = new Blob([decodeURIComponent(encodeURI(csvString))], { type: "text/csv;charset=utf-8;" });
navigator.msSaveBlob(blob, fileName);
} catch (e) {
alert("Error in IE. " + e);
}
} else {
//http://caniuse.com/#feat=download
try {
var a = document.createElement('a');
a.href = 'data:attachment/csv,' + csvString;
a.target = '_blank';
a.download = fileName;
document.body.appendChild(a);
a.click();
} catch (e) {
alert("Error while save using download attribute. " + e);
}
}