Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Mon, 24 Mar 2008 01:34:24 +0100,    group: microsoft.public.inetsdk.programming.webbrowser_ctl        back       


DOM access in NavigateComplete2 handler   
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();
date: Mon, 24 Mar 2008 01:34:24 +0100   author:   Jan Ostedt

Re: DOM access in NavigateComplete2 handler   
"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
date: Sun, 23 Mar 2008 20:44:12 -0400   author:   Igor Tandetnik

Re: DOM access in NavigateComplete2 handler   
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.
date: Mon, 24 Mar 2008 02:20:28 +0100   author:   Jan Ostedt

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us