使用javascript创建一个txt文件 [英] Create a txt file with javascript
问题描述
您好,
我正在尝试创建一个可以创建文本文件的javascript函数,这样我就可以在其中编写一些信息并稍后阅读。
我正在使用ActiveXObject(" Scripting.FileSystemObject)",
函数makefile(){
var fso; var该文件;
fso = new ActiveXObject(" Scripting.FileSystemObject");
thefile = fso.CreateTextFile(" c:\\ test .txt",true);
fso.close()
}
但没有发生任何事情,
所以请帮助我,
谢谢你
Hi there,
i''m trying to create a javascript function that would create a text file so i can write some informations in it and read it later.
I''m using the "ActiveXObject("Scripting.FileSystemObject")",
function makefile(){
var fso;var thefile;
fso = new ActiveXObject("Scripting.FileSystemObject");
thefile=fso.CreateTextFile("c:\\test.txt",true);
fso.close()
}
but nothing is happening,
so please help me,
Thank u
推荐答案
我不熟悉Active X,但是当我在我的计算机上尝试你的代码时,错误说该对象不支持该方法(fso.close())。代码工作正常,没有fso.close()并成功创建了一个名为test.txt的文件。
希望我帮助:)。
I am not familiar with Active X, but when I tried your code on my computer, the error said that the object doesn''t support that method ( fso.close() ). The code worked fine without the fso.close() and successfully created a file named test.txt.
Hope I helped :).
使用file.close()而不是fso.close()。
Use thefile.close() instead of fso.close().
你好,
我正在尝试创建一个可以创建文本文件的javascript函数,这样我就可以在其中编写一些信息并稍后阅读。
我正在使用ActiveXObject(& ; Scripting.FileSystemObject")",
函数makefile(){
var fso; var thefile;
fso = new ActiveXObject(" Scripting.FileSystemObject");
thefile = fso.CreateTextFile(" c:\\test.txt",true);
< br $> b $ b fso.close()
}
但没有任何事情发生,
所以请帮助我,
谢谢你b $ b
Hi there,
i''m trying to create a javascript function that would create a text file so i can write some informations in it and read it later.
I''m using the "ActiveXObject("Scripting.FileSystemObject")",
function makefile(){
var fso;var thefile;
fso = new ActiveXObject("Scripting.FileSystemObject");
thefile=fso.CreateTextFile("c:\\test.txt",true);
fso.close()
}
but nothing is happening,
so please help me,
Thank u
这可能只在IE浏览器上支持。此外,允许网页创建文件是一个安全漏洞。如果你只需要记住值,为什么不使用cookie呢?
This will probably only be supported on IE browsers. Also, allowing a web page to create files is a security hole. If you need to just remember values why not use cookies instead?
这篇关于使用javascript创建一个txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!