本地 JavaScript 可以在同一台本地计算机上编辑/保存文件吗?如何使用jQuery?
我正在构建一个本地运行的 CSS 驱动的站点地图,用于审核大型 Intranet 站点。我已经编写了代码,可以调出一个上下文菜单,其中提供了对 index.html 的 DOM 进行更新的选项。我想将这些更改保存到index.html。
我知道 JavaScript 不允许对客户端文件系统进行操作,但我也读到过,如果从本地计算机检索 JavaScript,则允许操作客户端文件系统。
任何人都可以确认这一点,并为我指明如何在不设置本地服务器的情况下完成此操作的正确方向吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以使用 Filewriter 对象写入本地文件系统,如下所述: http ://www.html5rocks.com/en/tutorials/file/filesystem/
也可以使用 文件系统访问 API。
It is possible to write to the local filesystem using the Filewriter object, as described here: http://www.html5rocks.com/en/tutorials/file/filesystem/
It is also possible to edit local files using the File System Access API.
我认为即使在 IE 的受信任区域中也是不可能的,至少对于纯 JavaScript 来说是不可能的(您可以使用 activeX 控件/也许是 flash 或 silverlight 并具有正确的信任级别)。
这是一个稍微不同的主题,但有一篇关于 HTML 5 本地存储的文章可能有助于背景阅读:http: //diveintohtml5.ep.io/storage.html
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