开发者

Reading / Writing files in Javascript - IE6

开发者 https://www.devze.com 2023-02-23 21:13 出处:网络
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 :-

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 distri开发者_开发知识库bute 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?


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.


I don't know if it's supported in IE6, but JScript appears to have some level of support for this through FileSystemObject.

var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c:\\testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();

According to Write binary data with FileSystemObject write(), ADODB.Stream appears to be an alternative.


For strictly local IE work use HTA Applications. Then you can access local resources (text files, ADO databases) without security problems.


try to read this post: Read/write to file using jQuery

Hope this helps.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消