views:

101

answers:

5

i need to create a temp file to store user settings on the client side .it it possible to create a simple log file by JavaScript ?

+1  A: 

If you want to store user settings, you should:

  1. use cookies
  2. store client information on the server

The ability for a webpage to access an individual's hard disk would be hazardous. However, as Trey pointed out below, you can use:

vol7ron
There are some other options for storing information on the client side (HTML5 storage for example), but cookies are the most reasonable choice. Evercookie uses many alternative storage methods: http://samy.pl/evercookie/
Trey
Valid point and worth mentioning edited answer. It's a much better alternative than the FSO.
vol7ron
+3  A: 

You have a few options:

  • Cookies
  • localStorage
  • database

Check this link:

Creating a file is possible only in IE using ActiveX objects.

BrunoLM
+1 for local storage.
casablanca
A: 

Try this anyway

var fso = new ActiveXObject("Scripting.FileSystemObject");
varFileObject = fso.OpenTextFile("C:\\Sachin.txt", 2, true,0); // 2=overwrite, true=create if not exist, 0 = ASCII
varFileObject.write("File handling in Javascript");
varFileObject.close();

http://www.codeproject.com/KB/scripting/JavaScript__File_Handling.aspx

But i dont think you have to do this type of experiments. You can create and do many file manipulations using server side languages.Thats better

zod
Wouldn't this be Windows/IE only?
vol7ron
+1  A: 

Storing the data in cookies would be the perfect solution.

It's light, and almost any browser has cookies enabled by default.

Victor Z.
A: 

If you can live with the user having to actively store the file, Downloadify allows you to generate a client side "download" on the fly.

Pekka