利用Blob, a.download, URL.createObjectURL模拟下载文件
来源:互联网 发布:淘宝手机市场 编辑:程序博客网 时间:2024/06/06 02:52
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>利用Blob对象创建文件</title></head><body> <textarea name="" id="downloadFileTextarea" cols="30" rows="10"></textarea> <br> <button id="downloadFileButton">downloadFileButton</button> <script> function downloadFile(fileName, content, blobOptions) { // blobOptions = { // type: 'text/csv', // endings: 'native' // or transparent // }; blobOptions = blobOptions || {}; var blob = new Blob([content], blobOptions); var a = document.createElement('a'); a.innerHTML = fileName; // 指定生成的文件名 a.download = fileName; a.href = URL.createObjectURL(blob); document.body.appendChild(a); var evt = document.createEvent("MouseEvents"); evt.initEvent("click", false, false); a.dispatchEvent(evt); document.body.removeChild(a); } downloadFileButton.onclick = function() { downloadFile('downloadFile.txt', downloadFileTextarea.value); }; </script></body></html>
0 0
- 利用Blob, a.download, URL.createObjectURL模拟下载文件
- Framework7中利用download和external实现a标签下载文件和图片
- Framework7中利用download和external实现a标签下载文件和图片
- Download+URL+断点下载
- angular下载文件数据流:乱谈 Blob 与 Object URL
- Windows.url.createObjectURL()
- 前端页面利用Blob对象创建文件进行下载
- URL.createObjectURL和URL.revokeObjectURL
- URL.createObjectURL和URL.revokeObjectURL
- URL.createObjectURL和URL.revokeObjectURL
- URL.createObjectURL和URL.revokeObjectURL
- URL.createObjectURL和URL.revokeObjectURL
- URL.createObjectURL和URL.revokeObjectURL
- URL.createObjectURL和URL.revokeObjectURL
- URL.createObjectURL和URL.revokeObjectURL
- android文件下载!download!
- android文件下载!download!
- download 文件下载
- Asp.Net 常用工具类之加密——非对称加密RSA算法
- repo&git&gerrit联系和使用
- 浅谈二路归并排序
- Android EventBus实战
- 如何实现大数据价值最大化?且听这位委员的建议
- 利用Blob, a.download, URL.createObjectURL模拟下载文件
- Dmaven.multiModuleProjectDirectory system propery is not set.
- oracle函数命令
- PAT_A 1125. Chain the Ropes (25)
- 导出excl
- CORS(跨域资源共享)
- [绍棠] bitcode问题
- 【技巧】各国时间显示
- React Native UI学习