Can local JavaScript edit/save files on same local

2019-07-27 19:18发布

问题:

I'm building a little locally run CSS driven site map for auditing a huge intranet site. I've already coded the ability, to bring up a context menu which provides for options to make updates to the DOM of index.html. I would like to save these changes to index.html.

I know JavaScript doesn't allow manipulation to the client file system, but I've also read in places that it is allowed if the JavaScript is retrieved from the local machine.

Can anyone confirm this and point me in the right direction on how this can be done WITHOUT setting up a local server?

回答1:

It is possible to write to the local filesystem using the Filewriter object, as described here: http://www.html5rocks.com/en/tutorials/file/filesystem/



回答2:

I don't think this is possible even in IE's trusted zone, at least not with pure javascript (you may be able to with an activeX control / maybe flash or silverlight with the right trust levels).

It's a slightly different subject, but there is a writeup on HTML 5 local storage which may help for background reading: http://diveintohtml5.ep.io/storage.html