Question

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

Was it helpful?

Solution

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.

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

OTHER TIPS

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top