Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function saveFile(content, fileName) {
- const textFile = this.makeTextFile(content);
- const link = document.createElement('a');
- link.download = fileName;
- link.href = textFile;
- const el = document.querySelector('body');
- el.appendChild(link);
- link.click();
- el.removeChild(link);
- }
- function makeTextFile(text) {
- const data = new Blob([text], { type: 'text/plain' });
- const textFile = window.URL.createObjectURL(data);
- return textFile;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement