Forgive a newbie-ish question. :)
I find that with complicated multi-frame pages (e.g. www.cnn.com) I get a document complete event for every single frame. Most of these are ad frames of course. Is there a way to obtain the "real" URL of the site, i.e. www.cnn.com in this case, without having to deal with all the other frames
Alternatively is there a status flag that identifies the final frame, or is it safe to assume that the last frame that I receive notification of is the "real" site frame
I have also found that with both IE6 and IE7 I occasionally never receive a document complete event for the "real" frame, in other words I get a dozen or more ad-based frames and nothing else, and yet the site correctly loads in the browser.
I am using IHTMLDocument2::get_URL to obtain the URL at the document complete event.
Thanks!
Graeme

Document Complete event for multiple frames
JGttttt
I'm still finding that certain sites do not always deliver the parent frame to my OnDocumentComplete handler though. www.luxist.com is a case in point. It has about 6 ad frames and then the www.luxist.com frame itself. About 50% of the time I do not catch the www.luxist.com frame.
Any ideas why this is flakey Is it an IE bug or me I wonder If someone has time perhaps they could try their own code on this site and see if they always get the parent frame
Thanks,
Graeme
Kartit
Hi
This method fails with the refresh (F5)! Try with http://www.microsoft.com/windows/ie/default.mspx or http://www.cnn.com/
Does somebody knows the solution
_mAyDaY_
Werner Clausen
Sharath is correct below is some code that might help.
STDMETHODIMP CHelloWorld::OnDocumentComplete(IDispatch *pDisp, VARIANT *pvarURL)
// Convert the IDispatch into IWebBrowser2{
CComQIPtr<IWebBrowser2> spTempWebBrowser = pDisp; // Is this event associated with the top-level browser
if (spTempWebBrowser && m_spWebBrowser && m_spWebBrowser.IsEqualObject(spTempWebBrowser))
{ // Gets document object from browser...
hr = m_spWebBrowser->get_Document(&spDispDoc);
if (SUCCEEDED(hr))
{
}
return hr;
}
bheybi
wormbyte
coolcoder
No, I meant there is no BeforeNavigate2/DocumentComplete for the main page, there would be BeforeNavigate2/DocumentComplete for subframes in the page. I created a small page which has the following -
<html>
<body>
<iframe src="http://www.google.com"/>
Some Tex for main page
</body>
</html>
Now, when I load the document, I get a BeforeNavigate2/DocumentComplete twice (one for the main document & one for the iframe). But if I do a refresh, I get only one and its for the iframe and none of the main page. Regarding sample code for detecting the refresh, I had come across this on codeproject.com (http://www.codeproject.com/internet/detecting_the_ie_refresh.asp). But again these solutions are mainly heuristics based and guess works.
HTH,
Sharath
rodgerst
JRLiem
to antonio : sorry ,I have not subroutine in VB
chuncheng
Basiclife
LiveGadgets
in vc6 CHTMLVIEW::OnDocumentComplete(VARIANT *pvarURL) has only one parameter. Do I have to upgrade to vc7 or higt realse
dcohn
Hi Chuncheng,
Would you have this subroutine in Visual Basic
Many thanks,
Antonio
kryptonneke
Thanks for your quick answer.
But, Are you telling that the solution for 'Multiple DocumentComplete' just works until the refresh button is used
How could I combine a solution for 'Multiple DocumentComplete' and a solution for the 'Refresh'
Do you have a good sample solution for the refresh
Thanks.
amitsinha
OK, the bug seems to be on my side. I rewrote my comparison for the top level browser and it seems to work great now. I do always get the top level/parent frame.
Thanks again,
Graeme