I have a problem with embedding a VBScript to my Javascript in a .js
file. I want to place a title
to my alert boxes, so I want to use the VBScript.
I have a .js
file, and this is what I want to insert in my .js
file.
<script language="VBScript">
Function makeMsgBox(tit, mess, icon, buts, defs, mode)
butVal = icon + buts + defs + mode
makeMsgBox = MsgBox(mess, butVal, tit)
End Function
</script>
But it gives me an error, I think it does not allow me to insert a VBScript in my Javascript file.
You cannot have the script declaration <script language="VBScript">
in a .js file. You also cannot have a VBScript function in a .js file.
You can try creating a .wsf file within which you can use both JavaScript an VBScript.
I am not clear about what all the parameters in your function are doing but here's how you can use both JavaScript and VBScript in the same Windows Script File and even call each other's functions:
<?xml version="1.0" ?>
<package>
<job>
<script language="VBScript">
Function makeMsgBox(tit,mess,buts)
makeMsgBox = MsgBox (mess,buts,tit)
End Function
</script>
<script language="JavaScript">
var YES_NO_CANCEL = 3;
makeMsgBox("VBScript message box", "Calling from JavaScript", YES_NO_CANCEL);
</script>
</job>
</package>