Possible Duplicate:
how to write a variables's content to a file in JavaScript
I have this piece of code to create a text file. How can I write to this text file?
function makefile() {
var fso;
var thefile;
fso = new ActiveXObject("Scripting.FileSystemObject");
thefile=fso.CreateTextFile("C:\\tmp\\MyFile.txt",true);
thefile.close()
}
Bear in mind this will only work in IE with the correct "relaxed" security permissions.
All the information can be found under FileSystemObject Basics.
When you
CreateTextFile
(orOpenAsTextStream
in write mode) you get a TextStream object back which has aWriteLine
method, among others. Please see the examples for "the code".Happy coding.
Here's one way: