javascript code to save a txt file

后端 未结 6 1162
走了就别回头了
走了就别回头了 2021-01-06 12:50

can any body tell me how i create a .txt file using javascript which is browser compatable too.

and after creating the file it gives the save as diaglog box so that

6条回答
  •  清歌不尽
    2021-01-06 13:44

    One may indeed initiate data URL downloads, including in a way to prompt a file dialog (though not with a default path or even file type). See https://stackoverflow.com/a/13696029/271577 for such a solution (along with text link examples). That being said, opening the content in a new tab via data URLs may be a better solution if you can get users to manually save using their browser.

提交回复
热议问题