Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. function saveFile(content, fileName) {
  2. const textFile = this.makeTextFile(content);
  3. const link = document.createElement('a');
  4. link.download = fileName;
  5. link.href = textFile;
  6. const el = document.querySelector('body');
  7. el.appendChild(link);
  8. link.click();
  9. el.removeChild(link);
  10. }
  11.  
  12. function makeTextFile(text) {
  13. const data = new Blob([text], { type: 'text/plain' });
  14. const textFile = window.URL.createObjectURL(data);
  15. return textFile;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement