Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi friends i am new to this blog, I am going to creating application like text editor using javascript, I am trying to create a new text file using ActiveXObject window method by clicking the button. Its creating a file but i want to create a new textfile when i clicked the button..
here the code which i used for creating file..
function createfile()
{
var file;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.OpenTextFile("C:\Libraries\Documents\NewFile.txt", 8, true, 0);
s.WriteLine(......);
s.Close();
}
please help me...
Posted
Updated 9-Feb-17 23:22pm
Comments
Richard C Bishop 28-Mar-13 17:32pm    
I don't think Java Script has a WriteLine() method, it is just .Write.
[no name] 28-Mar-13 17:42pm    
If it is creating a file, which is what you want to do, then what is the problem?
Sergey Alexandrovich Kryukov 28-Mar-13 17:44pm    
Do you think using ActiveX in HTML's JavaScript is at all acceptable? :-)
—SA
Member 9950476 29-Mar-13 14:47pm    
i want to create multiple text files..

1 solution

First of all, it's a really bad thing to use ActiveX object in JavaScript, virtually in all cases. This won't ever be supported by all browsers and platforms, and, more importantly, is utterly unsafe. If any experienced user will see that you are doing such things, such person will never use your products or products of your company, as it would suggest that such company does not consider very basic security practices.

And you really never need it for your purpose. As to the creation of the text editors, they can be pure JavaScrip tools working on all platforms. For example, look at this HTML (not just text) WYSIWYG editor:
http://en.wikipedia.org/wiki/TinyMCE[^],
http://www.tinymce.com/[^].

You can look at the source code and get the basic ideas.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900