Click here to Skip to main content
13,552,183 members
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

1 solution

Rate this: bad
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.
    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;}

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

Advertise | Privacy |
Web01-2016 | 2.8.180515.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2018
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