【问题标题】:Textbox in HTA after text is submitted, remove text from textbox提交文本后HTA中的文本框,从文本框中删除文本
【发布时间】:2012-11-07 09:47:38
【问题描述】:

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

我制作了一个简单的 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>

【问题讨论】:

  • 您的checkEnter() 永远不会被调用。在在线分配中它应该是:onkeydown="checkEnter();",现在属性包含一个字符串(“checkEnter”)。我认为 DOM 属性在 VBScript 中也是区分大小写的,应该有 .cancelBubble.returnValue
  • @Teemu DOM 属性在 VBScript 中不区分大小写,但我同意像使用它们一样使用它们是一个好习惯。

标签: vbscript hta


【解决方案1】:

只需在checkEnter 中拨打removetext

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-21
    • 1970-01-01
    • 1970-01-01
    • 2022-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-04
    相关资源
    最近更新 更多