当onkeypress事件发生时,HTA应用程序无法识别VBScript子例程 [英] The HTA application doesn't recognize the VBScript subroutine upon onkeypress event
问题描述
I'm trying to replicate this tutorial, running a VBScript subroutine upon a certain keyboard event. Consider the HTA/VBScript code below:
<HTML>
<HEAD>
<HTA:APPLICATION ID="HelloExample" BORDER="thick" BORDERSTYLE="complex" />
<SCRIPT Language="VBScript">
Sub RunScript()
If window.event.Keycode = 13 Then
Msgbox "You pressed the Enter key."
End If
End Sub
</SCRIPT>
</HEAD>
<BODY onkeypress="RunScript()">
</BODY>
</HTML>
但是,我收到错误消息:
However, I get the error messages:
之后
此页面上的脚本中存在错误
"RunScript";未定义
An error has accused in the script on this page
"RunScript" is undefined
如果您能帮助我知道问题出在哪里以及如何解决,我将不胜感激.感谢您的提前支持.
I would appreciate it if you could help me know what is the problem and how I can resolve it. Thanks for your support in advance.
P.S..由于结束说明中所述的错字,所以没有发生此问题.我从该字段中非常常见的来源复制并粘贴了这篇文章,这可能发生在其他人身上
P.S. This issue did not happen because of a typo as is described in the closing description. I copy and pasted this post from a very common source in the field and this might happen to other people
推荐答案
Vbscript不支持双引号.您需要直接用双引号
"
代替.您的代码没问题.这是它的外观.
Vbscript doesn't support double quote "
. You need straight double quote "
instead. Your code is alright. Here is how it should look like.
<HTML>
<HEAD>
<HTA:APPLICATION ID="HelloExample" BORDER="thick" BORDERSTYLE="complex" />
<SCRIPT Language="VBScript">
Sub RunScript()
If window.event.Keycode = 13 Then
Msgbox "You pressed the Enter key."
End If
End Sub
</SCRIPT>
</HEAD>
<BODY onkeypress="RunScript()">
</BODY>
</HTML>
告诉我它是否有效.
这篇关于当onkeypress事件发生时,HTA应用程序无法识别VBScript子例程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!