Calling VBScript from JavaScript or vice versa?

2019-02-12 17:50发布

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

3条回答
我命由我不由天
2楼-- · 2019-02-12 18:09

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

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

查看更多
Explosion°爆炸
3楼-- · 2019-02-12 18:16

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("")'>

see here for a more in depth example: http://docs.google.com/Doc?id=ajh85hfcbjj6_457g7v6fgfh

查看更多
在下西门庆
4楼-- · 2019-02-12 18:25

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
查看更多
登录 后发表回答