Skip to content

Instantly share code, notes, and snippets.

View vherasme's full-sized avatar

Victor M vherasme

  • Dow Jones
  • Barcelona
  • 03:29 (UTC +01:00)
View GitHub Profile
@vherasme
vherasme / downloadString.js
Created December 28, 2019 13:30 — forked from danallison/downloadString.js
download string as text file
function downloadString(text, fileType, fileName) {
var blob = new Blob([text], { type: fileType });
var a = document.createElement('a');
a.download = fileName;
a.href = URL.createObjectURL(blob);
a.dataset.downloadurl = [fileType, a.download, a.href].join(':');
a.style.display = "none";
document.body.appendChild(a);
a.click();