JavaScript uses FileSystemObject object to write the content of a text file. filesystemobject
This example describes how to use a FileSystemObject object to write text files in JavaScript. Share it with you for your reference. The details are as follows:
This code is mainly used to practice the JavaScript FileSystemObject object, which allows JavaScript to write content to a text file. You can specify the path of this TXT file by yourself, then define the content to be written and run the code. You will find that the content in the original TXT text has changed.
Shows the running effect:
The Code is as follows:
<Html>
However, in some cases, the browser reports an error and fails to create an object.
During debugging in F12 developer mode, the automation server fails to create an object when it runs to the new ActiveXObject line.
Solution:
Internet Explorer-> Tools-> Internet Options-> Security-> Custom Level-> Settings
-> Set "initialize and execute scripts for ActiveX controls that are not marked as secure scripts" to enable and confirm.
Note:
Enabling this option can only be used to debug local code. Remember to change it before accessing other websites.
Otherwise, malicious scripts will have all the permissions to read, write, and traverse your local files through IE!
I hope this article will help you design javascript programs.