我可以在单个HTA中混合使用VBScript和JScript吗?

时间:2022-11-22 22:44:32

Is it possible to use both JScript and VBScript in the same HTA? Can I call VBScript functions from JScript and vice-versa? Are there any "gotchas," like the JScript running first and the VBScript running second (classic ASP pages have this issue).

是否可以在同一个HTA中同时使用JScript和VBScript?我可以从JScript调用VBScript函数,反之亦然吗?是否有任何“陷阱”,如首先运行的JScript和运行第二个的VBScript(经典ASP页面有此问题)。

3 个解决方案

#1


11  

Yeah, just separate them into different script tags:

是的,只需将它们分成不同的脚本标签:

<script language="javascript">
   // javascript code
</script>

<script language="vbscript">
   ' vbscript code
</script>

Edit: And, yeah, you can cross call between Javascript and VBScript with no extra work.

编辑:是的,你可以在Javascript和VBScript之间进行交叉调用而无需额外的工作。

Edit: This is also true of ANY Windows Scripting technology. It works in WSF files and can include scripts written in any supported ActiveScript language such as Perl as long as the engine is installed.

编辑:任何Windows Scripting技术也是如此。它适用于WSF文件,并且可以包含使用任何受支持的ActiveScript语言(如Perl)编写的脚本,只要安装了引擎即可。

Edit: The specific "gotcha" of all JScript being executed first, then VBScript is related to how ASP processes scripts. The MSHTA host (which uses IE's engine) does not have this problem. I'm not much into HTAs though, so I can't address any other possible "gotchas".

编辑:首先执行所有JScript的特定“问题”,然后VBScript与ASP处理脚本的方式有关。 MSHTA主机(使用IE的引擎)没有这个问题。我不是很喜欢HTA,所以我无法解决任何其他可能的“陷阱”。

#2


0  

Also you can give references between them. For example: at the background some function on vbscript handle with database and FSO issues, and let javascript create user interfaces and dialogs etc. with DOM in frontline. Whenever you need you can call both functions from each script sides. In js you can call vbs function, and also in vbscript you can call js functions. Then you can use their returns where you call them. Regards

您也可以在它们之间提供参考。例如:在后台有一些关于vbscript的函数处理数据库和FSO问题,让javascript在前线用DOM创建用户界面和对话框等。只要您需要,您可以从每个脚本端调用两个函数。在js中你可以调用vbs函数,也可以在vbscript中调用js函数。然后你可以在你调用它们时使用它们的返回值。问候

#3


0  

Event handlers (like Onclick) should have the code prefixed with "javascript:" or "vbscript:"

事件处理程序(如Onclick)应该具有前缀为“javascript:”或“vbscript:”的代码

#1


11  

Yeah, just separate them into different script tags:

是的,只需将它们分成不同的脚本标签:

<script language="javascript">
   // javascript code
</script>

<script language="vbscript">
   ' vbscript code
</script>

Edit: And, yeah, you can cross call between Javascript and VBScript with no extra work.

编辑:是的,你可以在Javascript和VBScript之间进行交叉调用而无需额外的工作。

Edit: This is also true of ANY Windows Scripting technology. It works in WSF files and can include scripts written in any supported ActiveScript language such as Perl as long as the engine is installed.

编辑:任何Windows Scripting技术也是如此。它适用于WSF文件,并且可以包含使用任何受支持的ActiveScript语言(如Perl)编写的脚本,只要安装了引擎即可。

Edit: The specific "gotcha" of all JScript being executed first, then VBScript is related to how ASP processes scripts. The MSHTA host (which uses IE's engine) does not have this problem. I'm not much into HTAs though, so I can't address any other possible "gotchas".

编辑:首先执行所有JScript的特定“问题”,然后VBScript与ASP处理脚本的方式有关。 MSHTA主机(使用IE的引擎)没有这个问题。我不是很喜欢HTA,所以我无法解决任何其他可能的“陷阱”。

#2


0  

Also you can give references between them. For example: at the background some function on vbscript handle with database and FSO issues, and let javascript create user interfaces and dialogs etc. with DOM in frontline. Whenever you need you can call both functions from each script sides. In js you can call vbs function, and also in vbscript you can call js functions. Then you can use their returns where you call them. Regards

您也可以在它们之间提供参考。例如:在后台有一些关于vbscript的函数处理数据库和FSO问题,让javascript在前线用DOM创建用户界面和对话框等。只要您需要,您可以从每个脚本端调用两个函数。在js中你可以调用vbs函数,也可以在vbscript中调用js函数。然后你可以在你调用它们时使用它们的返回值。问候

#3


0  

Event handlers (like Onclick) should have the code prefixed with "javascript:" or "vbscript:"

事件处理程序(如Onclick)应该具有前缀为“javascript:”或“vbscript:”的代码