This example describes how JavaScript uses the FileSystemObject object to write the contents of a text file. Share to everyone for your reference. Specifically as follows:
This code is mainly to practice JavaScript FileSystemObject object, use it to let JavaScript write to a text file content, this TXT file path you can specify, and then define what to write, run the code, You will find that the contents of the original TXT text have changed.
The effect is as shown in the following illustration:
The specific code is as follows:
However, in some cases the browser will complain that the object could not be created.
F12 developer Mode Debugging Discovery: The Automation server failed to create the object when it ran to the new ActiveXObject.
Workaround:
IE browser-> tool->internet option-> security-> Custom Level-> settings
-> "Initialize and execute scripts for ActiveX controls not marked as safe for scripting" is set to Enabled, OK.
Attention:
Enabling this option is only available for debugging local code and must be remembered before accessing other web sites.
Otherwise malicious script will be through IE with read, write, traverse your local files and so on all the permissions!
I hope this article will help you with your JavaScript programming.