本地HTML能var fso, f; fso = new ActiveXObject("Scripting.FileSystemObject"); f = fso.CreateTextFile("c:\\testfile.txt", true); f.WriteLine("This is a test."); f.Close(); f = fso.GetFile("c:\\testfile.txt"); f.Delete();
能,不过有提示<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312"> <title> new document </title> <meta name="keywords" content=""> <meta name="description" content=""> </head> <body> <script type="text/javascript"> <!-- var fileName = "d:\\test\\11.txt" var fso = new ActiveXObject("Scripting.FileSystemObject"); var f;if (!fso.fileexists(fileName)) { f = fso.CreateTextFile(fileName); } else { f = fso.OpenTextFile(fileName,8); }f.write(new Date()); //--> </script> </body> </html>
不行啊 17行有错误 网页错误详细信息用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022) 时间戳: Wed, 25 May 2011 06:08:02 UTC 消息: 路径未找到 行: 17 字符: 1 代码: 0 URI: file:///D:/simulator.html
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.CreateTextFile("c:\\testfile.txt", true);
f.WriteLine("This is a test.");
f.Close();
f = fso.GetFile("c:\\testfile.txt");
f.Delete();
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title> new document </title>
<meta name="keywords" content="">
<meta name="description" content="">
</head> <body>
<script type="text/javascript">
<!--
var fileName = "d:\\test\\11.txt"
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f;if (!fso.fileexists(fileName)) {
f = fso.CreateTextFile(fileName);
}
else {
f = fso.OpenTextFile(fileName,8);
}f.write(new Date());
//-->
</script>
</body>
</html>
不行啊 17行有错误
网页错误详细信息用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
时间戳: Wed, 25 May 2011 06:08:02 UTC
消息: 路径未找到
行: 17
字符: 1
代码: 0
URI: file:///D:/simulator.html