By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,400 Members | 1,335 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,400 IT Pros & Developers. It's quick & easy.

how to create text file in javascript

P: 11
Hi,

I would like to know if it is possible to use JavaScript to write to a text file. I tried using FileSystemObject in JavaScript. However, it gives the following error : "Automation server can't create object". Does anyone know what is going wrong here?



Expand|Select|Wrap|Line Numbers
  1. var fso = new ActiveXObject("Scripting.FileSystemObject");
  2. var s = fso.CreateTextFile("C:\test.txt", true);
  3. s.WriteLine("helloworld");
  4. s.Close(); 
  5.  
thanks
Oct 22 '07 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
It will probably be caused by the security settings in your browser. You'll have to allow ActiveX objects/scripts to run. Note that you shouldn't use this setting for browsing the Internet.
Oct 22 '07 #2

P: 11
Thanks its working.. but when update the file into ftp.. whoever using that page
they have to set the security settings?????...

It will probably be caused by the security settings in your browser. You'll have to allow ActiveX objects/scripts to run. Note that you shouldn't use this setting for browsing the Internet.
Oct 22 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Thanks its working.. but when update the file into ftp.. whoever using that page
they have to set the security settings?????...
Well, it is creating a file on their system, so yes.

You'll probably have to include a message informing your users that this page will only work in IE with ActiveX enabled and remind them to revert back afterwards. In IE7, I think a bar appears at the top which allows the ActiveX to run for that page only.
Oct 22 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.