Access IE's document's parentWindow
-
hi, I am trying to capture events happening on IE (especially anchor click). I used typical IHTMLDocumentEvent2_Event method, but unfortunately this method was blocking up mouse activiteis(wheeling, selection and such) So I tried to use custmoized handler that I found at http://west-wind.com/WebLog/posts/393.aspx[^] But to do that, I need to access IE.docment.parentWindow to get IHTMLEvetObj. I am using SHDocVw.InternetExplorer not WebBrowser nor AxWebBrowser, so it did not allow to access the actual IE window to retrieve events. such as IHTMLDocument2 document = IE.document as IHTMLDocuemnt2; then, when I tried to do "document.parentWindow.@event" I reports InvalidCastException. Is there any one who has suggestions. Thanks
-
hi, I am trying to capture events happening on IE (especially anchor click). I used typical IHTMLDocumentEvent2_Event method, but unfortunately this method was blocking up mouse activiteis(wheeling, selection and such) So I tried to use custmoized handler that I found at http://west-wind.com/WebLog/posts/393.aspx[^] But to do that, I need to access IE.docment.parentWindow to get IHTMLEvetObj. I am using SHDocVw.InternetExplorer not WebBrowser nor AxWebBrowser, so it did not allow to access the actual IE window to retrieve events. such as IHTMLDocument2 document = IE.document as IHTMLDocuemnt2; then, when I tried to do "document.parentWindow.@event" I reports InvalidCastException. Is there any one who has suggestions. Thanks
You can try basic a debugging technique: enter this line double d = document.parentWindow; Now, of course, this will not compile cleanly, and that is just what we want! Look at the error message and it will tell you that it can't convert from type zzz to double. (zzz will be a real type name, of course.) Now you know that this should work, so enter it: zzz z = document.parentWindow as zzz; Then try to proceed from there. One step at a time.