showing results for - "dynamically download different filetypes in javascript"
Helene
09 Jan 2019
1function download(filename, text) {
2  var element = document.createElement('a');
3  element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
4  element.setAttribute('download', filename);
5
6  element.style.display = 'none';
7  document.body.appendChild(element);
8
9  element.click();
10
11  document.body.removeChild(element);
12}