Local JavaScript - write to local file

前端 未结 3 463
遇见更好的自我
遇见更好的自我 2021-02-03 11:01

I have some JavaScript code loaded from a local HTML file (without going through a webserver).. i.e., opened using file://

Is there a way the JavaScript cod

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-03 11:22

    There's no native API* for File System access in browsers. You need that first!

    For example, in Internet Explorer, there's an ActiveX object for it:

    var fso = new ActiveXObject("Scripting.FileSystemObject");
    

    ...but it requires the user to relax their browser settings. On other browsers, you may be able to use a jar (Java Archive) file.

    You could also see what non-browser JavaScript containers offer, e.g. Microsoft HTA files (HTML Application) will support the Windows ActiveX FileSystemObject fine, providing your Virus Checking Software allows HTA files to execute.

提交回复
热议问题