日期:2014-05-16 浏览次数:20434 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS文件操作</title>
<script type="text/javascript">
function creatFile(){
var fso, ts;
var ForWriting= 2;
fso = new ActiveXObject("Scripting.FileSystemObject");
ts = fso.OpenTextFile("d:\\test.txt", ForWriting, true);//创建
// 写一行,并且带有新行字符。
ts.WriteLine("Testing 1, 2, 5.") ;//写入
// 向文件写三个新行字符。
ts.WriteBlankLines(3) ;
// 写一行。
ts.Write ("This is a test.");
ts.Close(); //关闭
}
</script>
</head>
<body>
<input type="button" value="creatFile" onclick="creatFile()"/>
</body>
</html>