Justin Voss Justin Voss - 5 months ago 18
Javascript Question

Can I Mix VBScript and JScript in a Single HTA?

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).


Yeah, just separate them into different script tags:

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

<script language="vbscript">
   ' vbscript code

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

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.

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".