如何为downoad创建字符串到文本文件? [英] how to create string to text file for downoad?

查看:75
本文介绍了如何为downoad创建字符串到文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在javascript文件中有字符串,现在我想将其转换为文本文件并要下载,

我使用了以下代码,

函数createFile(){
var object = new ActiveXObject("Scripting.FileSystemObject");
var file = object.CreateTextFile("C:\\ Hello.txt",false);
file.WriteLine(''Hello World'');
file.WriteLine(``希望是有羽毛的东西,栖息在灵魂上.'');
file.Close();
}

还有这个,


函数WriteToFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:\\ Test.txt",true);
s.WriteLine(''Hello'');
s.Close();
}


还尝试了downloadify js,
但它不起作用,还有其他方法吗?

i have string in javascript file, now i want to convert it in text file and want to download it,

i have used following code,

function createFile(){
var object = new ActiveXObject("Scripting.FileSystemObject");
var file = object.CreateTextFile("C:\\Hello.txt", false);
file.WriteLine(''Hello World'');
file.WriteLine(''Hope is a thing with feathers, that perches on the soul.'');
file.Close();
}

and also this,


function WriteToFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:\\Test.txt", true);
s.WriteLine(''Hello'');
s.Close();
}


and also tried downloadify js,
but its not working, is there any other method?

推荐答案

got,

ActiveXObject允许文件写入,
但Firefox不支持,
仅在IE中受支持.
got,

ActiveXObject allows file to write,
but it is not supported in Firefox,
only supported in IE.


这篇关于如何为downoad创建字符串到文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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