Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

javascript - localStorage like storage alternatives for HTA

I am developing a HTA application, for that I need to store some data at client side using JavaScript. Like localStorage in HTML5, I am just looking for same functionality if possible. Please let me know if I can found any.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In HTA you are free to use any ActiveX you want. FileSystemObject is the best solution for simple folder and file actions, though it can read and write text files only. With this ActiveX Control you can also create and delete folders and files, retrieve their properties etc.

FSO and HTAs are still working in IE9. However, all development and support was ended at IE7, so all HTML and JavaScript capabilites (and bugs) are on that level too. To utilize features available to IE9, use <meta http-equiv="x-ua-compatible" content="ie=9"> in <head>. This works with single pages only, and can't be used within frameset-pages.

FileSystemObject: http://msdn.microsoft.com/en-us/library/6kxy1a51%28v=vs.84%29.aspx HyperText-Applications: http://msdn.microsoft.com/en-us/library/ms536471%28v=vs.85%29.aspx

Basic functions in FileSystemObject

Create an ActiveX:

fso=new ActiveXObject('Scripting.FileSystemObject');

Write a file:

var oStream=fso.OpenTextFile('SAVE_PATH',2,true);
oStream.WriteLine('YOUR_DATA'); // Usually looped for several lines
oStream.Close();

Open a file:

var iStream=fso.OpenTextFile('OPEN_PATH',1,false);
data=iStream.ReadLine(); // Usually looped for several lines
iStream.Close();

See also WScript.Shell: http://msdn.microsoft.com/en-us/library/98591fh7%28v=vs.84%29.aspx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...