js_将字符串保存为文本文件

将字符串保存为文本文件

注:文件保存在当前电脑、下载文件夹中

 1 //保存
 2     var mySave = function () {
 3         console.log(event)                    
 4         const content = 'a plain text.'
 5         const blob = new Blob([ content ], {type: "text/plain;charset=utf-8"})
 6         const objectURL = URL.createObjectURL(blob)
 7         var tempConfirm1 = confirm("objectURL:" +objectURL)//确认      
 8         const anchor = document.createElement('a')
 9         anchor.href = objectURL
10         anchor.download = "plaintext.txt"
11                     
12         anchor.click()
13 
14         URL.revokeObjectURL(objectURL)
15 
16     }
View Code

 

posted @ 2023-06-19 10:19  AutomationAnywhere  阅读(304)  评论(0)    收藏  举报