Binding events to handlers 
Author Message
 Binding events to handlers

I wish to capture events generated by an atomation object in a VB script executed
in WSH.
On msdn I've found how to do this in Visual Basic, but I can't figure how to do
in VBScript.
For example in the following script, how can I bind the OnQuit event of
InternetExplorer object with an suitable handler? I suppose I've to define a class
but I don't know how.

Option Explicit
Dim IE

Private Sub IE_onclick()
    IE.navigate " http://www.*-*-*.com/ "
End Sub

Sub IE_onQuit
    MsgBox("IE quitted")
End Function

Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "about:blank"
IE.visible=True
Set IE.Document.onClick=getref("IE_onClick")

MsgBox("Click here to finish ")
Set IE = Nothing



Thu, 24 Jul 2003 07:07:02 GMT  
 Binding events to handlers
You have to use the WScript.CreateObject method and not the VBScript
CreateObject function. The second argument is handler prefix.

  Set IE = WScript.CreateObject("InternetExplorer.Application","IE_")

=-=-=
Steve
-=-=-


Quote:
> I wish to capture events generated by an atomation object in a VB script
executed
> in WSH.
> On msdn I've found how to do this in Visual Basic, but I can't figure how to
do
> in VBScript.
> For example in the following script, how can I bind the OnQuit event of
> InternetExplorer object with an suitable handler? I suppose I've to define a
class
> but I don't know how.

> Option Explicit
> Dim IE

> Private Sub IE_onclick()
>     IE.navigate "http://www.microsoft.com"
> End Sub

> Sub IE_onQuit
>     MsgBox("IE quitted")
> End Function

> Set IE = CreateObject("InternetExplorer.Application")
> IE.navigate "about:blank"
> IE.visible=True
> Set IE.Document.onClick=getref("IE_onClick")

> MsgBox("Click here to finish ")
> Set IE = Nothing



Thu, 24 Jul 2003 08:03:04 GMT  
 Binding events to handlers



[...]

Quote:
> These would work as intended from a strongly typed language like VB or VC++,

just not from script...

Thank you very much.



Thu, 24 Jul 2003 09:38:50 GMT  
 Binding events to handlers


Fri, 19 Jun 1992 00:00:00 GMT  
 Binding events to handlers

| You have to use the WScript.CreateObject method and not the VBScript
| CreateObject function. The second argument is handler prefix.
|
|   Set IE = WScript.CreateObject("InternetExplorer.Application","IE_")

How can i do this with JavaSript?

Thanx, Ansgar



Mon, 22 Sep 2003 20:26:08 GMT  
 Binding events to handlers
var IE = WScript.CreateObject("InternetExplorer.Application","IE_");

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:


> | You have to use the WScript.CreateObject method and not the VBScript
> | CreateObject function. The second argument is handler prefix.
> |
> |   Set IE = WScript.CreateObject("InternetExplorer.Application","IE_")

> How can i do this with JavaSript?

> Thanx, Ansgar



Tue, 23 Sep 2003 07:01:01 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Add an event handler to the actual event handler for an element

2. JScript event handler for ActiveX DLL events within IE

3. Determining which object fired event from event handler.

4. onchange event/event handler not triggering

5. WSH, WebBrowser & Dynamic Event Binding

6. Client-Side VBscript and event binding.

7. Bind Events To Existing Internet Explorer?

8. EVENT binding question ..the use of ::

9. event handler for server sided sub or function

10. How is an event handler setup in HTML

11. TreeView Control Event handler HTML?

12. Event handler

 

 
Powered by phpBB® Forum Software