Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function saveFile(name, blob) {
- var w = window;
- var d = w.document;
- var link = d.createElement('a');
- link.setAttribute('download', name);
- link.href = w.URL.createObjectURL(blob);
- link.onclick = function () {
- d.body.removeChild(this);
- };
- link.style.display = 'none';
- d.body.appendChild(link);
- link.click();
- }
- saveFile('hello.txt', new Blob(['Hello, world!']));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement