【发布时间】:2014-08-16 23:29:13
【问题描述】:
我有一个脚本可以让我在我的电脑上隐藏一个文件夹(使用批处理文件)。我刚刚为它实现了一个用于密码的 hta 应用程序,所以它更安全。现在我遇到的问题是,如果我想按 Enter 键在 hta 应用程序上提交表单,它只会清除密码字段并且什么都不做。我希望它具有与按下 OK 按钮相同的效果。这是我的批处理文件的 hta 部分:
:HTA
<html>
<head>
<title>Password Entry</title>
<hta:application id="htaid"
applicationName="Password"
border="thin"
borderStyle="normal"
caption="yes"
contextMenu="no"
maximizeButton="no"
minimizeButton="yes"
navigable="yes"
showInTaskbar="yes"
singleInstance="yes"
sysmenu="yes"
version="0.1">
<script language="vbscript">
window.resizeTo 210, 110
Sub SaveBatch()
set fs=CreateObject("Scripting.FileSystemObject")
strFile=fs.GetAbsolutePathName(fs.BuildPath(fs.GetSpecialFolder(2), "UserIn.bat"))
set ts=fs.OpenTextFile(strFile, 2, True)
ts.WriteLine "set PASSWORD=" & document.Forms(0).elements("password").value
ts.Close
End Sub
</script>
</head>
<body>
<form style=margin-top:-15;>
Password:
<br><input type=password name=password>
<br><input type=button language="vbscript" value="OK" onclick="SaveBatch : Window.Close">
</form>
<script language=vbscript>
document.Forms(0).elements("password").focus
</script>
</body>
</html>
我尝试创建一个检查键码 13 onkeypress 的方法,还尝试将其实现到密码字段的 html 部分。它要么执行以前的操作,要么导致脚本错误。
【问题讨论】:
标签: batch-file button hta enter onkeypress