在 DHTML/AJAX 页面的情况下,如何使用浏览器辅助对象 (BHO) 获取完整的 HTML 正文?
我正在编写一个 BHO,用于分析从 'DWebBrowserEvents2'
的 'onDocumentComplete'
事件中获取的 HTML。目前它工作正常,除非我有一个 DHTML/AJAX
页面,其中 HTML 句柄传递得太快。
例如,我尝试在 'http://www.google.com'
上使用它。通过 'onDocumentComplete'
事件,我可以获取大部分页面,但在最顶部的链接/锚点中,地图、视频、orkut 等的 'href'
不可用(通常是 javascript:void(0)
)。
有谁知道如何在页面完全加载时而不是仅在加载框架/正文时捕获它?
谢谢,
更新
MSHTML API 似乎存在一些问题。我已经在 MSDN 论坛上发布了同样的问题并得到了一些回复。我还详细说明了我的问题和发现...
万一有人找到某种方法来解决那么请分享...
谢谢,
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....
In case someone finds some way to solve this then please do share...
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AJAX DHTML 更改大多不会导致进一步的
onDocumentComplete
调用。您需要注册进一步的窗口或文档事件,例如
DISPID_HTMLWINDOWEVENTS2_ONLOAD
。一种方法是建议您使用通用事件接收器接口提供的 com 对象的窗口。
hr = AtlAdvise(winDisp, pWinHandler, DIID_HTMLWindowEvents2, &dwCookie);
当触发此进一步事件时,重新检查文档,您会发现它已更新。
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.