How can I access the JavaScript global object (“window”) inside an embedded browser object (the IWebBrowser2 interface)?

StackOverflow https://stackoverflow.com/questions/4695427

Question

I have an HTML page which embeds an IWebBrowser2 ActiveX (i.e. the control is essentially an Internet Explorer browser). I need to write JavaScript in this HTML page which will remove any window.onresize handler from the page loaded in the IWebBrowser2 control.

IWebBrowser2 exposes the DOM through IWebBrowser2::Document, but this is equivalent to window.document. Is there any way I can get access to window or window.onresize?

Was it helpful?

Solution

You should be able to use document.parentWindow:

var controlWindow = control.document.parentWindow;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top