How to create and save a text file with JavaScript

前端 未结 4 988
一生所求
一生所求 2020-12-21 04:26

Do you know any cross-browser method to create and save a file with JavaScript on the client-side?

Considerations:

  1. I can\'t save it on the server becau
4条回答
  •  情深已故
    2020-12-21 05:10

    Your only options are to use persistance APIs from HTML5 or to create a browser plugin (activex control on IE, NPAPI plugin on others) that can do the file access for you. You could use FireBreath to do this, and it would be relatively simple if you know C++.

    That said, it is a really dangerous idea; it is difficult to prevent people from using your plugin in other pages, so your plugin has to somehow be smart enough to keep itself from being abused by malicious sites that want to read (or even write) arbitrary data to your hard drive.

    There is, after all, a reason why browsers don't natively support this. I'd look at HTML5.

提交回复
热议问题