
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.