使用javascript创建文本文件 [英] creating a text file using javascript

查看:105
本文介绍了使用javascript创建文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,我是这个博客的新手,我将使用javascript创建类似文本编辑器的应用程序,我试图通过单击按钮使用ActiveXObject窗口方法创建一个新的文本文件。它创建了一个文件,但我想在我点击按钮时创建一个新的文本文件..

这里我用来创建文件的代码..

function createfile()

{

var file;

var fso = new ActiveXObject(Scripting.FileSystemObject);

var s = fso.OpenTextFile(C:\ Library \ Document \ NewFile.txt,8,true,0);

s.WriteLine(......);

s.Close();

}

请帮帮我...

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...

推荐答案

首先,在JavaScript中使用ActiveX对象是一件非常糟糕的事情,几乎在所有情况下都是如此。所有浏览器和平台都不会支持这一点,更重要的是,它完全不安全。如果任何有经验的用户会发现您正在做这样的事情,那么此类人员将永远不会使用您公司的产品或产品,因为这表明该公司不会考虑非常基本的安全措施。



你真的永远不需要它为你的目的。至于文本编辑器的创建,它们可以是适用于所有平台的纯JavaScrip工具。例如,看看这个HTML(不仅仅是文本)WYSIWYG编辑器:

http://en.wikipedia .org / wiki / TinyMCE [ ^ ],

http://www.tinymce.com/ [ ^ ]。



您可以查看源代码并获取基本想法。



-SA
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


这篇关于使用javascript创建文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆