View Full Version : Textare to .txt

08-04-2008, 05:35 AM
Hi all

I have this little script that I found a while ago,

function save()
str = document.forms[4].textarea.value;
mydoc = window.open();

and im now wondering if there is any Client Side way of making the text add to a text file rather than overwriting it?


08-04-2008, 10:06 AM
You know all this is for IE only, right?

Without looking it up, you might be able to read CallLog.txt to the window using execCommand as part of the process of writing to the widow before saving. This wouldn't actually append to the file, it would still overwrite it, but the result would be as if it had been appended to.

I just did look it up, you cannot. Here's the list of Commands (command identifiers) available for execCommand:


Open is listed as not supported. There are no other ones that look like they would read a file.

There is another method for actually appending to a file, but there will be Active X warnings, even for a live page using these methods, as they could write malicious files:

<script type="text/javascript">
// Instantiate a File System ActiveX Object:
var a, fso = new ActiveXObject("Scripting.FileSystemObject");
// Invoke the method:
try {
a = fso.CreateTextFile("c:\\webwork2\\testfile.txt", false);
a = fso.OpenTextFile("c:\\webwork2\\testfile.txt", 8)
// Do something with it:
a.WriteLine("This is a test. 4");
// Close the connection: