Hello, In my MFC (CHtmlView) application I would like to modify the downloaded page via the DOM in my NavigateComplete2 handler. If I place the code below in that handler I end up with "<body><p> </p></body>" in bstrOuterHTML instead of the HTML of the downloaded page. How come? Isn't it possible to access the DOM in the NavigateComplete2 handler? Any help would be greatly appreciated. Thanks in advance! Regards Jan IWebBrowser2* pIWebBrowser2; pDisp->QueryInterface(IID_IWebBrowser2,(void**)&pIWebBrowser2); IDispatch* pDispatch; pIWebBrowser2->get_Document(&pDispatch); pIWebBrowser2->Release(); IHTMLDocument2* pIHTMLDocument2; pDispatch->QueryInterface(IID_IHTMLDocument2,(void**)&pIHTMLDocument2); pDispatch->Release(); IHTMLElement* pBodyElement; pIHTMLDocument2->get_body(&pBodyElement); pIHTMLDocument2->Release(); BSTR bstrOuterHTML; pBodyElement->get_outerHTML(&bstrOuterHTML); SysFreeString(bstrOuterHTML); pBodyElement->Release();
"Jan Ostedt" wrote in message news:vnodu3l5vma5n63f8cpgtnu2c0h4doh8kn@4ax.com > In my MFC (CHtmlView) application I would like to modify the > downloaded page via the DOM in my NavigateComplete2 handler. It's too early. NavigateComplete2 is fired as soon as the first byte of response is received from the server. The DOM of the page hasn't been built yet. You need to wait until DocumentComplete. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
On Sun, 23 Mar 2008 20:44:12 -0400, "Igor Tandetnik" wrote: Igor, Thank you very much for your quick answer. I misinterpreted the docs that say that the document object is available at NavigateComplete2 time. You are right, they do not say that the DOM is ready to be used. Thanks again for clearing that up. Best Regards Jan >It's too early. NavigateComplete2 is fired as soon as the first byte of >response is received from the server. The DOM of the page hasn't been >built yet. You need to wait until DocumentComplete.