js读写文件(ActiveXObject只支持ie7以前的版本)

来源:互联网 发布:js导出table到excel 编辑:程序博客网 时间:2024/06/05 22:17

<script type="text/javascript">

function CreateFile(xml) {

var fso, tf;

//这是在IE7以前的版本中

if (window.ActiveXObject) {
//支持-通过ActiveXObject的一个新实例来创建XMLHttpRequest对象

fso = new ActiveXObject("Scripting.FileSystemObject");

tf = fso.CreateTextFile("D:\\Downloads\\mxgraph-master\\javascript\\examples\\xmlData\\helloworld.xml", true); //创建一个文件夹
// 写一行,并且带有新行字符。
tf.WriteLine(xml);
// 向文件写三个新行字符。  
tf.WriteBlankLines(3);
// 写一行。
// tf.Write("This is a test.");
tf.Close(); //关闭
}

}

</script>
0 0
原创粉丝点击