Search code examples
c++ajaxdhtmlatlbho

How to get complete HTML body using browser helper object (BHO) in case of DHTML/AJAX page?


I'm writing a BHO that analyze the HTML taken from the 'onDocumentComplete' event of 'DWebBrowserEvents2'. Currently it works fine, unless I have a DHTML/AJAX page, where HTML handle is delivered too soon.

For sample, I tried using it on 'http://www.google.com'. From the 'onDocumentComplete' event I can get most of the page but in the topmost link/anchors, the 'href' for maps, videos, orkut etc. is not available (normally it is javascript:void(0)).

Has anyone any ideas how to capture it when the page is fully loaded rather than just when the frame/body is loaded?

Thanks,

UPDATE

It seems there is some problem with the MSHTML API. I have posted the same question on MSDN forum and some response. Also I have detailed out my problem and findings....

http://social.msdn.microsoft.com/Forums/en-US/ieextensiondevelopment/thread/d517dbd1-df22-4dce-8ff9-0ca6786757f9

In case someone finds some way to solve this then please do share...

Thanks,


Solution

  • The AJAX DHTML changes mostly don't cause a further onDocumentComplete call.

    You need to register for further Window or Document events such as DISPID_HTMLWINDOWEVENTS2_ONLOAD.

    One method is to advise the window of a com object that you provide with the generic event sink interface. hr = AtlAdvise(winDisp, pWinHandler, DIID_HTMLWindowEvents2, &dwCookie);

    When this further event is triggered re examining the document you will find that it is updated.