Click here to Skip to main content
12,949,700 members (87,113 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
I am facing a problem with the IE extension I am currently building. The IE extension is supposed to change the content of the webpage I am currently viewing. The problem is, sometimes it works and yet other times it doesn't. I kept pursuing the problem till i managed to find out that the call to the function which manipulates the page's content is performed before the entire content of the page (DOM) is loaded.

Is there a way for me to ensure that the complete page along with its DOM is loaded first, then perform the modifications?!

I am currently capturing these events within the DISPID_DOCUMENTCOMPLETE event.
Posted 5-Feb-13 3:01am
Daroosh745

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try Applying this code within your Invoke() method. Then, you'll be capable of catching all the events within the DIID_HTMLDocumentEvents2 Interface that are raised by your document. One of these events would be the onPropertyChange event which is raised everytime your document gets updated.
    webBrowser->get_Document(&idisp);
    idisp->QueryInterface(IID_IHTMLDocument2, (void**)&doc2);
 
/* Register Our WebBrowser->doc2 to the HTMLDocumentEvents2 Interface ==> To catch events within the (HTMLDocumentEvents2 Interface) */
    IConnectionPointContainer *cpc=0; 
    if (doc2) doc2->QueryInterface(IID_IConnectionPointContainer, (void**) &cpc);
    IConnectionPoint* cp=0; 
    if (cpc) cpc->FindConnectionPoint(DIID_HTMLDocumentEvents2, &cp);
 
//Do your processing here...
 
// Release Your Pointers    
    if (cp) hr=cp->Advise(static_cast<idispatch*>(this), &cookie);
    if (cp) cp->Release(); 
    if (cpc) cpc->Release(); 
    if (!doc2 )
    {release(); return E_FAIL;}
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,489
CHill60 3,380
Maciej Los 2,913
Jochen Arndt 1,935
ppolymorphe 1,820


Advertise | Privacy | Mobile
Web02 | 2.8.170524.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100