提交文本后HTA中的文本框,从文本框中删除文本

时间:2012-11-07 09:47:38

标签: vbscript hta

不确定是否有人问过这个问题(我找不到)......

我制作了一个简单的Google搜索HTA文件...

它确实没有问题,但是我希望文字在输入后输入消失?

我在搜索之后尝试了BasicTextBox.Value =“”但是这除了最后一个字母之外还要采取一切措施..

我希望我有意义,有人可以帮助我吗?

<html>
<head>
<title>Search Google</title>

<HTA:APPLICATION 
ID="objHTAHelpomatic"
border="thin"
borderStyle="normal"
caption="yes"
maximizeButton="no"
minimizeButton="no"
showInTaskbar="yes"
windowState="normal"
innerBorder="no"
navigable="no"
scroll="no"
scrollFlat="no"
sysMenu="yes"
icon="htaicon.ico"
>
</head>

<SCRIPT Language="VBScript">

 Sub Window_OnLoad
 window.resizeTo 100, 100
  End Sub


sub checkEnter
With document.parentWindow.event
if .keycode = 13 then
Const NORMAL_WINDOW = 1
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "https://www.google.com.au/search?q=" & BasicTextBox.Value
Else
.cancelbubble = false
.returnvalue = true
End if
End With

  call removetext

End sub 

sub removetext
   BasicTextBox.Value = ""
end sub

</SCRIPT>
<body bgColor="gray" STYLE="font:8pt arial; color:white">

Search Google
<input type="text" onKeydown=checkEnter name="BasicTextBox" size="10">

</body>
</html>

1 个答案:

答案 0 :(得分:0)

只需在removetext中致电checkEnter

sub checkEnter
    Const NORMAL_WINDOW = 1
    With document.parentWindow.event
        if .keycode = 13 then
            Set objShell = CreateObject("Shell.Application")
            objShell.ShellExecute "https://www.google.com.au/search?q=" & BasicTextBox.Value
            call removetext
        End if
End With