GoingTharn
GoingTharn

Reputation: 1131

Calling VBScript from JavaScript or vice versa?

Is it possible to call a VBScript function from a JavaScript call, or alternately call JavaScript from a VBScript call?

Upvotes: 9

Views: 23710

Answers (3)

mrTomahawk
mrTomahawk

Reputation: 962

This is also possible within HTA's by specifying the language when the function is called, like this:

<input id="renameIcon" 
       name="renameIcon" 
       type="image" 
       src="images/rename.ico" 
       onclick=renameUser() 
       onmouseover='vbscript: if showStat <> "busy" Then call showStatus(button4.title)' 
       onmouseout='vbscript: if showStat <> "busy" Then call showStatus("")'>

Upvotes: 1

bulevardi
bulevardi

Reputation: 69

Calling a VBScript function from Javascript

Your VBScript:

Function myVBFunction()
  ' here comes your vbscript code
End Function

Your Javascript:

function myJavascriptFunction(){
  myVBFunction();           // calls the vbs function
}
window.onload = myJavascriptFunction;

Calling a Javascript function from VBScript

Function myVBFunction()
  myJavascriptFunction()  
End Function

Upvotes: 6

Patrick Cuff
Patrick Cuff

Reputation: 29786

Yes, if your main script is a Windows Script File (WSF).

WSF files can include other script files and execute code from multiple engines.

Upvotes: 3

Related Questions