If you want to do so for your internal purpose or have full faith on your client you can very well do this using ActiveX scripts.
But, this technique will only be useful if the client machine supports ActiveX. Scripting.FileSystemObject is an ActiveXObject, which has the function CreateTextFile(parameter1, parameter2) to write to the file system of the machine where the Javascript will be executed.
CreateTextFile() creates a file as specified in the first parameter and returns a TextStream object that actually writes to the specified file. The second parameter here accepts a Boolean value. If its value is true that means the file can be overwritten if it exists.
To write any content to the file WriteLine(“Text to write”) method of the TextStream object is used. To make the content permanent the file is closed using Close() method. This way we can write a file to store any text data only.
Here's a sample code snippet - (please remove all the whitespace, when you try to run it!)
< span onClick= " file() " >Hello < /span > < /p >
< SCRIPT LANGUAGE = " JavaScript " >
function file()
{
var ForAppending = 8;
var TriStateFalse = 0;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var newFile = fso.OpenTextFile("c:\\WINDOWS\\Desktop\\001122.html",
ForWriting, true, TriStateFalse);
}
< /SCRIPT >