Click here to Skip to main content
15,886,840 members
Please Sign up or sign in to vote.
4.00/5 (1 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

1 solution

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.
C++
    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;}
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900