不知大家有没有用过xmlhttp  在此组件中有一个onreadystatechange事件(用来反映当前状态的)是可以用javascript脚本来掉用的. 
例如:xmlhttp=new ActiveXObject("MSXML2.XmlHttp");
..............................
xmlhttp.onreadystatechange=function (){
   //............................
}
我现在在VB做的DLL中想实现类示的事件不知怎么做, 我用下面普通的事件定义方法在网页(javascript)中调用不到的 下面是我的代码:Private myState As Variant     
Dim WithEvents XInet As Inet           '定义Microsoft Internet Transfer 控件
Public Event onreadystatechange()      '定义的事件Public Sub uploadFile(dataStr As Variant)
 Set XInet = New Inet 
 XInet.URL = "http://10.17.45.148:8080/acxml.jsp?guid=123456"
 XInet.Execute , , dataStr 
End SubPrivate Sub XInet_StateChanged(ByVal State As Integer)
   myState = State
   RaiseEvent onreadystatechange
End SubPublic Property Get State() As Variant
 State = myState
End Property
我在javascript中调用onreadystatechange是调用不到的,不知xmlhttp组件的onreadystatechange事件是怎么做的? 他可以在脚本中调用.我找了一些关于回调事件的资料,但还是不知怎么做!

解决方案 »

  1.   

    要不你再等等吧,俺解决不了。再不用Google到国外的网站上查一下。
    帮你顶一下,等待高手的到来。
      

  2.   

    in msdn.netUsing HTML Components to Implement DHTML Behaviors in Script --------------------------------------------------------------------------------Dynamic HTML (DHTML) behaviors are components that can be implemented in a number of ways. For several years, the task of writing components has been limited to developers using Microsoft® Visual C++®, Microsoft Visual Basic®, and Java.As of Microsoft Internet Explorer 5, script developers can use HTML Component (HTC) or Microsoft Windows® Script Component (WSC) to implement their own DHTML behaviors in script, using Visual Basic Scripting Edition (VBScript), Microsoft JScript® (compatible with ECMA 262 language specification), or any third-party scripting language that supports the Microsoft ActiveX® Scripting interfaces.This article outlines the steps for using HTC files to create behaviors in script. For more information about how to create behaviors using WSC, see Microsoft Windows Script Technologies.This article assumes that the reader has a good understanding of script programming and is familiar with HTCs and DHTML behaviors. Implementing behaviors in Visual C++ is beyond the scope of this article. For more information about DHTML behaviors, HTCs, WSCs, and the Visual C++ interfaces involved in implementing behaviors, see Related Topics.After reading this article, you should be able to implement behaviors in your scripting language of choice, isolate script from your content, and reap the benefits of encapsulation and code reusability in your Web site.This article is divided into the following sections:HTC Overview
    Creating an HTC
    Exposing Properties
    Using the INTERNALNAME Attribute
    Exposing Methods
    Exposing Custom Events
    Receiving Notifications
    Scope Rules
    Timing Considerations
    Behavior-Related Enhancements to the DHTML Object Model
    Related Topics
      

  3.   

    Implementing Binary DHTML Behaviors --------------------------------------------------------------------------------Dynamic HTML (DHTML) behaviors can be implemented in script as well as in compiled languages, such as C++. This article focuses on the binary version of behaviors and outlines the steps for creating binary behaviors using Microsoft® Visual C++® version 5, Active Template Library (ATL) version 5, and ATL Service Pack 3 (SP3).For more information about DHTML behaviors and the concepts and benefits of using them, see Related Topics.This article is divided into the following sections:Options for Implementing Behaviors: ATL/COM vs. HTML Components
    Prerequisites and Dependencies
    How It's Done: Creating the C++ Behavior Project in Visual C++ 5.0
    Implementing the IElementBehavior Interface
    Implementing the IElementBehaviorFactory Interface
    Exposing Events, Properties, and Methods
    Implementing Object Security with the IObjectSafety Interface
    Putting it Together: Creating a Mouseover Binary Behavior Sample
    Related Topics
    Options for Implementing Behaviors: ATL/COM vs. HTML Components
    While HTML Component (HTC) can be used to provide a generic way of creating reusable components using scripting languages, binary behaviors can be used to better protect intellectual property. This is because, unlike an HTC, a binary behavior is compiled and, thus, cannot be read using the View Source command in a browser. In addition, binary behaviors do not work through scripting engine interfaces like HTCs do; instead, they directly call the underlying operating system, and this allows binary behaviors to have superior performance relative to HTCs.Microsoft Internet Explorer provides C++ interfaces as a means of implementing binary behaviors. With C++ behavior interfaces, a Component Object Model (COM) object can receive notifications, expose custom events, and access the containing page's DHTML Object Model.A Web developer can create binary behaviors using C++ behavior interfaces and ATL/COM techniques. Doing this extends the functionality of HTML pages without sacrificing the security of intellectual property. Intranet administrators also can take advantage of the performance of binary behaviors. For example, they can create binary behaviors to implement corporate-wide mandates, unique business rules, and flexible user management techniques for their intranets.Prerequisites and Dependencies
    This article assumes that the reader:Has a good understanding of C++ programming. 
    Is familiar with Visual C++ 5.0 and ATL. 
    Has a general understanding of DHTML Behaviors.
      

  4.   

    制作包含可在IE中被激发时间的ActiveX/COM,关键是要执行IElementBehavior Interface 与IElementBehaviorFactory Interface,VC中较简单,肯定能实现,但应该较麻烦
      

  5.   

    添加一个class module
    在这个module中加上
    Implements MSXML2.XMLHTTP就会有Private Property Let XMLHTTP_onreadystatechange(ByVal RHS As Object)End Property
      

  6.   

    llstone(stone) :我认为这样解决不了问题,现在free1978 (freebird) 的问题不是没有接口执行点(事件),而是没有执行IElementBehavior Interface 与IElementBehaviorFactory Interface等接口,造成IE 不能将javascript脚本与相应的事件相连接建议
    1.先用HTC试一下
    2.去微软新闻组问一下,最好是英文的--有了方法别忘了告诉大家一下
      

  7.   

    引用Library MSHTML
        C:\WINNT\system32\mshtml.tlb
        Microsoft HTML Object Library
    实现IElementBehavior Interface 与IElementBehaviorFactory Interface等接口关于IElementBehavior Interface 与IElementBehaviorFactory Interface等接口,在msdn.net中详细讲解