Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. </head>
  7. <body>
  8. <button id="btnRecord">download</button>
  9. <script type="text/javascript">
  10. const inputFile = document.querySelector('#inputFile');
  11.  
  12. btnRecord.addEventListener('click', function(e) {
  13. const blob = new Blob(['this is just a test'], {
  14. type: 'text/plain'
  15. });
  16. const url = URL.createObjectURL(blob);
  17. const a = document.createElement('a');
  18. a.style.display = 'none';
  19. a.href = url;
  20. a.download = 'test.txt';
  21. document.body.append(a);
  22. a.click();
  23. setTimeout(function() {
  24. document.body.removeChild(a);
  25. URL.revokeObjectURL(url);
  26. }, 0);
  27. });
  28. </script>
  29. </body>
  30. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement