Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- </head>
- <body>
- <button id="btnRecord">download</button>
- <script type="text/javascript">
- const inputFile = document.querySelector('#inputFile');
- btnRecord.addEventListener('click', function(e) {
- const blob = new Blob(['this is just a test'], {
- type: 'text/plain'
- });
- const url = URL.createObjectURL(blob);
- const a = document.createElement('a');
- a.style.display = 'none';
- a.href = url;
- a.download = 'test.txt';
- document.body.append(a);
- a.click();
- setTimeout(function() {
- document.body.removeChild(a);
- URL.revokeObjectURL(url);
- }, 0);
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement