Answers for "Dynamically download different filetypes in JavaScript"

0

Dynamically download different filetypes in JavaScript

function download(filename, text) {
  var element = document.createElement('a');
  element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  element.setAttribute('download', filename);

  element.style.display = 'none';
  document.body.appendChild(element);

  element.click();

  document.body.removeChild(element);
}
Posted by: Guest on April-28-2021

Code answers related to "Dynamically download different filetypes in JavaScript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language