如何从表单中获取文本并使用javascript保存在文本文件中
<html >
<head>
<link rel="shortcut icon" type="image/png" href="/favicon1.png" sizes="16x16" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login & Registration System</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<center>
<div id="login-form">
<form method="post">
<table align="center" width="30%" border="0">
<tr>
<td><font color="#001c4e" size=18px >
<b>Elvis Login</b></font></td>
</tr>
<tr>
<td><input type="text" id="resultname" name="user_name" placeholder="User ID" required /></td>
</tr>
<tr>
<td><input type="password" name="pass" placeholder="Your Password" required /></td>
</tr>
<div id="result"></div>
<script>
// Check browser support
function WriteToFile(f) { //added the form you clicked from
try {
alert("started");
var t = f.user_name.value;
alert(t);
var msg = t;
var fso, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
s = fso.OpenTextFile("C:\\Test\\Logfile.txt", 8, false);
s.writeline(msg);
s.Close();
alert("Comment Saved!");
}
catch (err) {
var strErr = 'Error:';
strErr += '\nNumber:' + err.number;
strErr += '\nDescription:' + err.description;
document.write(strErr);
}
}
$</script>
<tr>
<td><button type="submit" onclick="WriteToFile(this.form)" name="btn-login">Sign In</button></td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>
我需要从表单中获取用户名并将其保存在文本文件中。但此代码仅适用于IE浏览器。请提供建议。 有什么东西用于代替新的ActiveXObject? 我不想安装plugins.give其他建议