Guest User

Untitled

a guest
Jan 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. function downloadData(data, filename, type) {
  2. var file = new Blob(["\ufeff" + data], { type: type });
  3. if (window.navigator.msSaveOrOpenBlob)
  4. // IE10+
  5. window.navigator.msSaveOrOpenBlob(file, filename);
  6. else {
  7. // Others
  8. var a = document.createElement("a"),
  9. url = URL.createObjectURL(file);
  10. a.href = url;
  11. a.download = filename;
  12. document.body.appendChild(a);
  13. a.click();
  14. setTimeout(function() {
  15. document.body.removeChild(a);
  16. window.URL.revokeObjectURL(url);
  17. }, 0);
  18. }
  19. }
Add Comment
Please, Sign In to add comment