日期:2014-05-16  浏览次数:20347 次

JS文件操作
<!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>
1 楼 huangyunbin 2012-09-14  
我在ie6下是可以的,但是会弹出提示框
我在google浏览器下会报错:Uncaught ReferenceError: ActiveXObject is not defined
有办法让google浏览器也可以吗?