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

做~自己de王妃 提交于 2019-12-06 15:04:13

问题


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,


回答1:


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.



来源:https://stackoverflow.com/questions/3298160/how-to-get-complete-html-body-using-browser-helper-object-bho-in-case-of-dhtml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!