Use JavaScript to write to text file?

前端 未结 4 2050
失恋的感觉
失恋的感觉 2020-12-21 18:05

I have a need to capture the topics of a search from one of my blog pages and write it to text file for followup. I have been able to capture the input string, however, am n

4条回答
  •  醉话见心
    2020-12-21 18:10

    JavaScript cannot read/write files from the client or write files to the server (directly).

    If you want to write files to the server consider using server-side scripts that will interact with your javascript - and example on how to do this with a little bit of PHP.

    In terms of client file interaction this is simply impossible for security reasons (unless it is uploaded to the script in which case it is read accessible).

    You can however store data on clients - I have previously been using jStorage and highly recommend it. It works cross-browser (even on IE 6) and is extremely easy to use.

提交回复
热议问题