Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function download (text, name, type) {
- type = !type ? 'text/plain' : type;
- if(!text || !name) {
- console.warn('[Downloading File] Content and filename must be provided.');
- return false;
- }
- var a = document.createElement('a');
- var file = new Blob([text], {type: type});
- a.href = URL.createObjectURL(file);
- a.download = name;
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- };
Add Comment
Please, Sign In to add comment