开发者

Generate text/xml-file using javascript/jquery?

开发者 https://www.devze.com 2023-04-11 03:46 出处:网络
I would like to know if there is any开发者_如何转开发 way to generate a text/xml file in javascript. I want users to be able to fill out a page form when they are offline, save the data, and then use

I would like to know if there is any开发者_如何转开发 way to generate a text/xml file in javascript. I want users to be able to fill out a page form when they are offline, save the data, and then use the saved file at a later point in time. The browser will be IE, most likely IE7.

Thanks


The files should be stored on client filesystems, right?

In general, saving data on client's computer by a web script would be considered a security breach. I would avoid doing so but if it's one of your project requirements, you can give it a try.

Since the target platform would be IE, you can try ActiveX. Example code (not tested):

var fso  = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("c:\\path\\file.txt", true);
fh.WriteLine("Some text");
fh.Close();


You might have to use Flash in order to access the user's filesystem to save the file. That is the way most client-side components work if they need to create a file wholly on the client.

Time to learn ActionScript, and say goodbye to iDevices compatibility!

0

精彩评论

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

关注公众号