Click here to Skip to main content
11,640,521 members (61,918 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ IE9 BHO
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
Daroosh721

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
0 Mika Wendelius 330
1 OriginalGriff 175
2 Afzaal Ahmad Zeeshan 130
3 CPallini 125
4 Sergey Alexandrovich Kryukov 94
0 Mika Wendelius 200
1 OriginalGriff 145
2 CPallini 115
3 jgakenhe 40
4 sasanka sekhar panda 30


Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2015
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