在 Javascript 中读取/写入文件 - IE6
我需要一个 JavaScript 数据库存储系统,可以在本地磁盘上维护状态。
工作中的扳手来了:-
- 它只需要支持 Internet Explorer,但最低版本必须是 IE6
- 需要写入文件,以便稍后可以再次读取它们(在关闭并重新打开浏览器时)
- 不能有Web 服务器(除非它非常容易分发并且不需要安装),因为 HTML 页面将在 USB 上分发。
有谁知道这里可能有帮助的解决方案?
I need a database storage system for Javascript where the state can be maintained on the local disk.
Here comes the spanners in the works :-
- It only needs to support Internet Explorer but the minimum version must be IE6
- Files need to be written so they can be read in again later (upon closing and re-opening of browser)
- There can be no web server (unless it's extremely easy to distribute and does not require a install) since the HTML pages will be distributed on USB.
Does anyone know of any solutions that might help here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尽情享受 userData 的乐趣。显然它在 IE6/7 中满足您的要求
然后 localStorage for IE8/9
或者您可以使用更重的 store.js ,它可以执行以下操作:为您提供功能检测,并且显然适用于 IE6+。
它应该可以在 IE9 中运行,但没有保证。我会推荐 store.js,因为它更容易维护并且开箱即用。您还可以通过这种方式支持其他浏览器。
Have fun playing with userData. Apparently it does what you want in IE6/7
Then localStorage for IE8/9
Or you can use the heavier store.js which does the feature detection for you and apparently works in IE6+.
It should work in IE9 but no garantuees. I would recommend store.js as it's easier for maintenance and just works out of the box. You can also support other browsers that way.
我不知道 IE6 是否支持它,但 JScript 似乎通过
FileSystemObject
。根据 使用 FileSystemObject write() 写入二进制数据,
ADODB.Stream
似乎是一种替代方案。I don't know if it's supported in IE6, but JScript appears to have some level of support for this through
FileSystemObject
.According to Write binary data with FileSystemObject write(),
ADODB.Stream
appears to be an alternative.对于严格本地 IE 工作,请使用 HTA 应用程序。然后您就可以访问本地资源(文本文件、ADO 数据库)而不会出现安全问题。
For strictly local IE work use HTA Applications. Then you can access local resources (text files, ADO databases) without security problems.
尝试阅读这篇文章:使用 jQuery 读取/写入文件
希望这会有所帮助。
try to read this post: Read/write to file using jQuery
Hope this helps.
我建议您不要尝试使用 JavaScript 进行读/写,而是尝试在 USB 驱动器上嵌入小型 Web 服务器。我曾经为一个应用程序做过一次,效果很好。我使用了 卡西尼< /a> 网络服务器。
我在视觉工作室中创建了两个项目。首先,我创建了一个 ASP.Net 网站来读取/写入 SQLite 数据库。该网站显示了我的所有内容,其构建方式与任何其他 ASP.Net 网站一样。其次,我创建了一个 Windows 窗体应用程序来托管 Cassini Web 服务器,并向用户提供一个包含单个 Web 浏览器控件的表单。这使得用户体验非常简单...他们只需从 USB 驱动器的根目录中单击 MYAPP.EXE,表单就会打开,启动 Web 服务器,并将浏览器控件导航到网站的起始页。
I would suggest that you not try to read/write using JavaScript but instead head down the road of embedding a small web server on the USB drive. I did this for an app once and it worked out well. I used the Cassini web server.
I created two projects in visual studio. First, I created an ASP.Net web site to read/write from an SQLite database. This site displayed all my content and was built just like any other ASP.Net site. Second, I created a Windows Forms application that hosted the Cassini web server and presented the user with a form that contained a single web browser control. This made the user experience very simple ... they just clicked MYAPP.EXE from the root of the USB drive and the form opens, starts the web server, and navigates the browser control to the start page of the web site.