Bind Events To Existing Internet Explorer? 
Author Message
 Bind Events To Existing Internet Explorer?

I know that when you create an object, you can also assign event-handlers to
it, as follows:

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

...but I don't know how to assign event-handlers to an already-running
instance. For example, how would I assign a BeforeNavigate2 event handler to
an IE object gained through the following code?

var ie1=new ActiveXObject("Shell.Application").Windows(0);

Also, I note the Michael Harris states (in another message) that setting
Cancel to true won't work in the event handler (scripts aren't strongly
typed). Is there any other way I could cancel the event?

Thanks in advance,
Grant Husbands.



Thu, 24 Jul 2003 20:38:15 GMT  
 Bind Events To Existing Internet Explorer?
The WScript.ConnectObject is meant to do what you're trying to do.  But IE is one of the objects
that it doesn't work with (see the Remarks section in the ConnectObject documentation).

You might want to check out ScriptX from MeadCo - it should be able to do what you want (see the
ScriptX docs for the NewEventSink method).

MeadCo ScriptX 5.5 Release - build 5,50,0,158
http://www.meadroid.com/scriptx/beta/index.htm

Note that this *is* the release version despite the "beta" in the URL...

--
Michael Harris
Microsoft.MVP.Scripting
--

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

Quote:

> I know that when you create an object, you can also assign event-handlers to
> it, as follows:

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

> ...but I don't know how to assign event-handlers to an already-running
> instance. For example, how would I assign a BeforeNavigate2 event handler to
> an IE object gained through the following code?

> var ie1=new ActiveXObject("Shell.Application").Windows(0);

> Also, I note the Michael Harris states (in another message) that setting
> Cancel to true won't work in the event handler (scripts aren't strongly
> typed). Is there any other way I could cancel the event?

> Thanks in advance,
> Grant Husbands.



Fri, 25 Jul 2003 07:10:20 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. OnKeyDown-event: How to cancel the default action of function key's in Internet Explorer

2. OnKeyDown-event: How to cancel the default action of function key's in Internet Explorer

3. Internet Explorer Closing Events

4. OnKeyDown-event: How to cancel the default action of function key's in Internet Explorer

5. receive events from internet explorer object

6. receive events from internet explorer object

7. event generate when you maximize internet explorer?

8. Trapping ActiveX Events using JScript in Internet Explorer

9. Internet Explorer Object capture events

10. Using File Exists on Windows Explorer and Windows Media player shortcuts

11. WSH, WebBrowser & Dynamic Event Binding

12. Client-Side VBscript and event binding.

 

 
Powered by phpBB® Forum Software