How Can I Use Javascript Oo Classes From Vbscript, In An Asp-classic Or Wsh Environment?
I know I can call top-level functions defined in JS from VBScript, and vice versa, like this: <%@ language='Chakra' %>
Solution 1:
I don't know how to avoid the problem that VBScript cannot directly call a Javascript "constructor" function. The way I dealt with it was to simply define a shim: a top-level function in Javascript that invokes the constructor from within Javascript and returns the reference.
So:
<scriptlanguage='javascript'runat='server'>(function() {
MyObj = function() {
this.foo = ...
...
};
MyObj.prototype.method1 = function() { .. };
MyObj.prototype.method2 = function() { .. };
// define a shim that is accessible to vbscriptShim = {construct: function() { returnnewMyObj(); } };
}());
</script><scriptlanguage='vbscript'runat='server'>Dim foo
Set foo = Shim.construct()
...
</script>
Post a Comment for "How Can I Use Javascript Oo Classes From Vbscript, In An Asp-classic Or Wsh Environment?"