Q: I have an ActiveX control used on the web build under MFC. I want to be able to call a javascript
funtion on the webpage the control is hosted. How do I do this?
A: You can use execScript method of the IHTMLWindow2 interface.
Using GetControlUnknown you retrieve IUnknown interface of the browser object. Then you should do
QueryInterface for IWebBrowser2 interface. Then call IWebBrowser2::get_Doccument to obtain an
IHTMLDocument2 interface pointer and then call
IHTMLDocument2::get_parentWindow to obtain a pointer to
the IHTMLWindow2
interface.
本文介绍如何从ActiveX控件调用宿主网页上的JavaScript函数。通过使用IHTMLWindow2接口的execScript方法,获取浏览器对象的IUnknown接口,并进一步得到IWebBrowser2接口。然后通过IWebBrowser2::get_Document方法获取IHTMLDocument2接口,最后通过IHTMLDocument2::get_parentWindow获取IHTMLWindow2接口。

2570

被折叠的 条评论
为什么被折叠?



