I know I can call top-level functions defined in JS from VBScript, and vice versa, like this:
<%@ language="Chakra" %>
<script language= JavaScript runat= server >
function jsFunction1() {
for (var i=0;i<10;i++) Response.Write(i+"<br>");
vbFunction2();
}
</script>
<script language= VBScript runat= server >
Sub vbFunction1 ()
Response.Write("VB Hello <br/>" & VbCrLf)
jsFunction1()
End Sub
Sub vbFunction2 ()
Response.Write("VB Goodbye <br/>" & VbCrLf)
End Sub
</script>
<script language="JavaScript" runat="server">
vbFunction1();
</script>
我还可以将联合材料纳入VB文本模块,如:
<%@ language="VBScript" %>
<script language="Javascript" runat="server" src="includedModule.js"></script>
<script language="VBScript" runat="server">
....
</script>
......《公报》也规定了包括《宪章》规定的职能。
But suppose I have a Javascript class defined using prototypal OO, like this:
(function() {
MyObj = function() {
this.foo = ...
...
};
MyObj.prototype.method1 = function() { .. };
MyObj.prototype.method2 = function() { .. };
}());
我如何使用VB.A.的这个物体(ka类型、类别或类别)?
2. 范 The法......
Dim foo
Set foo = New MyObj
......不工作。
也没有
Dim foo
foo = MyObj()
...because apparently this
is not defined when the JS function is invoked
from VBScript. Or something.
因此,我如何能够这样做?
之所以如此,是很有价值的:在Javascript有可供使用的业务办公室图书馆,这一点将引人于使用VB文本。