I need to write to a text file using JavaScript. I have a machine I need to run some HTML file on and it uses JS to manipulate content. I want to log the changes the user makes in a text file, and the computer does not have and will never have any server-side scripting language. So I just wanna know how to append text to a txt file using JS only. Alternatively, running a batch script upon JS call that will do the work itself, is a good equivalent, but I'm sure it's the same level of difficulty...
The script will work on an IE only machine, but I need to be able to test it on other browsers as well... So I'm not sure how and if ActiveX works on Chrome for example, but if it doesn't, I need another solution... Help please! :)
-
Good luck... I doubt it's gonna work as well as you want.DanRedux– DanRedux2012年05月04日 00:26:22 +00:00Commented May 4, 2012 at 0:26
-
Why do you want to manipulate a text file? Do you need an actual .txt, or are you just looking for persistant client-side storage?st-boost– st-boost2012年05月04日 00:52:31 +00:00Commented May 4, 2012 at 0:52
-
The web app I'm making is a listing changer for some company. The limitation on that computer is that no software can be installed, including a server... and I need to create an automated log for the listing changes. I literally need just to write to a .txt file.casraf– casraf2012年05月06日 21:49:24 +00:00Commented May 6, 2012 at 21:49
2 Answers 2
Not exactly the solution I was looking for, but I ended up using cookies, which limits the amount of data I can hold to very little, but beats nothing.
Comments
While there's some promise with the new File API, you'll probably need to go with a server-sided language for reliable file-writing.
Some possible alternatives are to 'write' the changes to the localStorage, or perhaps to create a URI download. There's plenty of tutorials online for setting these up. Good luck!