var filename = "c://OurSiteData.txt";
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a, ForAppending, file;
ForAppending = 8;
file = fso.OpenTextFile(filename, ForWriting, false);
var file = fso.CreateTextFile(filename, true);
var filename = "c://data.txt";
if (confirm("Do you want to see what we put on your computer?"))
var fso, a, ForReading;
ForReading = 1;
fso = new ActiveXObject("Scripting.FileSystemObject");
file = fso.OpenTextFile(filename, ForReading, false);
var name = file.readline();
var password = file.readline();
document.write(name + "<br>");
This does NOT work in Netscape, without a bit of rigging, which I have not included becuase of security issues. When using this (It is ActiveX, and as the others here posted, browsers have a security issue with you writing on user's system), the user (who can disallow ActiveX - they get an error) or can have it allowed (not normal, but if set in security settings as allowed the script works silently) or they can have it prompted for (this is defualt in IE). If it is set to the default prompt for ActiveX, they see the following prompt:
The "if (confirm(............." is just incase you want to prompt them about what you put (note it writing it to the page with "document.write(..);" ) ...What you do with it once read is up to you!
Just remember, a small percentage of folks will get errors, most will get that alert, and NS users will get nothing but errors. Want to stop the NS errors and have this work in NS? Search for "Netscape PrivilegeManager" or "Netscape Security Privaleges" in any search.
Also, note: Where it has the word "ForWriting"...IF the file already exist, they will recieve an error on any browser as it tries to overwrite it, generally. You can replace this with "ForAppending", BUT the ForAppending adds the lines to the end of the file, and would later cuase a mess reading it in your scripts.
Search for "ActiveX write textfile", for more info.