English 中文(简体)
我如何在伙伴关系-地图学或WSH环境中利用Javascript OO课程?
原标题: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" %>

<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文本。

最佳回答

我不知道如何避免VB 无法直接称为“建筑”功能的问题。 我处理的方式是简单地界定一个要点:在 Java文中使用顶级功能,从 Java稿中援引建筑商,并退回参考。

因此:

<script language= javascript  runat= server >(function() {  
  MyObj = function() {  
    this.foo = ...  
    ...  
  };  

  MyObj.prototype.method1 = function() { .. };  
  MyObj.prototype.method2 = function() { .. };  

  // define a shim that is accessible to vbscript
  Shim = {construct: function() { return new MyObj(); } };

}());  
</script>

<script language= vbscript  runat= server >
  Dim foo
  Set foo = Shim.construct()
   ...
</script>
问题回答

暂无回答




相关问题
Session Management with Windows Authentication

In an ASP.NET web app, using Integrated Windows Authentication, is the session tied to the windows identity? In other words, if I login (using IWA) to the app, and the app stores some "stuff" in my ...

Using Elmah with Cassini

Does anyone know if I can use Elmah with Visual Studio build-in web server(aka Cassini)? I get it working easily on IIS, but using same configuration, it doesn t work with Cassini. When I requested ...

Setting hostname in IIS, include www?

I want to set the hostname for a website I m adding in IIS 7, however do I include the www in the hostname or not? because I want both www.mysite.com and mysite.com both to point to mysite on the ...

inetpub versus any other folder

I ve run websites out of inetpub, as well as from folders just residing on the C: drive. I wonder, are there any definitive advantages to running websites out of inetputwwwroot?

IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...

热门标签