我使用了以下代码:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("test.txt", true);
for(var j=1;j<9;j++)
{
s.WriteLine('Test' + j);
}
s.Close();
运行以上代码时出现以下错误: ReferenceError:未定义ActiveXObject
答案 0 :(得分:1)
ActiveXObject
仅适用于IE浏览器。所以每个其他的useragent都会抛出错误
在其他浏览器上, 你可以这样做:
答案 1 :(得分:0)
试试这个 这仅适用于IE8
<SCRIPT LANGUAGE="JavaScript">
function WriteToFile(passForm) {
set fso = CreateObject("Scripting.FileSystemObject");
set s = fso.CreateTextFile("C:\test.txt", True);
s.writeline("HI");
s.writeline("Bye");
s.writeline("-----------------------------");
s.Close();
}
</SCRIPT>
</head>
<body>
<p>To sign up for the Excel workshop please fill out the form below:
</p>
<form onSubmit="WriteToFile(this)">
Type your first name:
<input type="text" name="FirstName" size="20">
<br>Type your last name:
<input type="text" name="LastName" size="20">
<br>
<input type="submit" value="submit">
</form>
cridte @ 667776 @Faraona Faraona