mlabs

I'm trying to manipulate the DOM in a document associated with an IFRAME on a web page.The IFRAME loads itself dynamically using the src attribute, in response to a user click on a link.

In other scenarios, I am trapping OnDocumentComplete() and in there I am passed an IDspatch, from which I can get the associated IHTMLElement2 and insert some stuff..

However, in this case, OnDownloadComplete() passes me no IDispatch, so how can I figure out the associated IHTMLElement2 I need to modify some of the DOM that got downloaded...

TIA



Re: Internet Explorer Extension Development DownloadComplete vs DocumentComplete

Reza Nourai - MSFT

Let me see if I understand the scenario.

1. The page is finished loading. DocumentComplete fires.

2. The user clicks on something, causing you to set the src= attribute on an IFRAME via script.

3. Ones that src data is downloaded, you get DownloadComplete event

4. You want an IDispatch pointer to the downloaded content (presumably the content is a control or element) so you can query it for an IHTMLElement2

Is that correct





Re: Internet Explorer Extension Development DownloadComplete vs DocumentComplete

mlabs

correct... its a form with a rich text edior and a few buttons... i want to inject some javascript at this point which changes some attribs on the buttons.. before the download they dont exist....

Reza Nourai - MSFT wrote:

Let me see if I understand the scenario.

1. The page is finished loading. DocumentComplete fires.

2. The user clicks on something, causing you to set the src= attribute on an IFRAME via script.

3. Ones that src data is downloaded, you get DownloadComplete event

4. You want an IDispatch pointer to the downloaded content (presumably the content is a control or element) so you can query it for an IHTMLElement2

Is that correct





Re: Internet Explorer Extension Development DownloadComplete vs DocumentComplete

Reza Nourai - MSFT

One way to do this is to Query the browser for an IHTMLDocument2 interface after the DownloadComplete fires. Then you can crawl through the DOM via the all collection (this is where naming your injected form could come in handy), and then get the element that way.

Example:




IDispatch* pDisp;
IHTMLDocument2* pDOM;

pBrowser->get_Document(&pDisp);
pDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pDOM);

IHTMLElementCollection* pCollection;
pDOM->get_all(&pCollection);

CComVariant vElement(L"MyButton");
CComVariant vIndex(0,VT_I4);

pCollection->item(vElement,vIndex,&pDisp);

IHTMLElement* pElement;

pDisp->QueryInterface(IHTMLElement,(void**)&pElement);

// Now you have the IHTMLElement






Re: Internet Explorer Extension Development DownloadComplete vs DocumentComplete

Sdi

You may need to watch for BeforeNavigate2 events, so you know which named frames are being navigated. That way when DownloadComplete tells you that "somebody finished navigating", you can query the frames that you know were navigating to see which one is finished.





Re: Internet Explorer Extension Development DownloadComplete vs DocumentComplete

mlabs

thanks Reza and SDI - i will experiment with your suggestions...

i posted another question up here too.. 'more OnDocumentComplete' prbs .. to do with caching the IDispatch ptrs when they come in ... any thoughts on that

TIA