监控来自 IE BHO 的 ajax 调用
我正在尝试找到一种方法来检测 BHO 页面上的更改。对于 Firefox 版本的插件,我使用 DomNodeInserted
,但这在 IE 中不可用。我还研究过使用 onpropertychange
,但这只允许您监视单个元素(而不是子元素)。
我现在想知道是否可以监视 AJAX 请求何时被调用。如果是这样,我可以在 AJAX 请求完成后对页面进行更改。唯一的问题是,我找不到办法做到这一点。
到目前为止,这是我的尝试,根据 jeffamaphone 的建议,它不起作用,但也许它会唤起某人的记忆。
public class ChangeMonitor : IHTMLChangeSink {
public void Notify()
{
Trace.WriteLine("notified");
}
}
void registerMonitor()
{
HTMLDocument document = _webBrowser2.Document;
ChangeMonitor monitor = new ChangeMonitor();
IHTMLChangeSink changeSink = monitor;
IHTMLChangeLog changeLog = null;
((IMarkupContainer2)document).CreateChangeLog(changeSink, out changeLog, 1, 1);
}
I'm trying to find a way to detect changes on a page from a BHO. For the Firefox version of the plugin I'm using DomNodeInserted
, but this isn't available in IE. I've also looked at using onpropertychange
, but this only allows you to monitor a single element (not children).
I'm now wondering if it's possible to monitor when AJAX requests are called. If so, I can make the changes to the page after the AJAX request has completed. Only problem is, I can't find a way to do it.
Here's my attempt so far, based on jeffamaphone's suggestions, it doesn't work but maybe it'll jog someone's memory.
public class ChangeMonitor : IHTMLChangeSink {
public void Notify()
{
Trace.WriteLine("notified");
}
}
void registerMonitor()
{
HTMLDocument document = _webBrowser2.Document;
ChangeMonitor monitor = new ChangeMonitor();
IHTMLChangeSink changeSink = monitor;
IHTMLChangeLog changeLog = null;
((IMarkupContainer2)document).CreateChangeLog(changeSink, out changeLog, 1, 1);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于 IE,onreadystatechange 将作为相当于 DomNodeInserted。 DHTML 行为必须通过 htc 附加到元素,但 htc 文件不必存在:
BHO 可以注入脚本来处理事件。
For IE, onreadystatechange will work as an equivalent to DomNodeInserted. A DHTML behavior must be attached to the element via htc, but the htc file does not have to exist:
The BHO can inject the script to handle the event.
我从来没有这样做过,但我的理论是你可以使用 IMarkupContainer2::CreateChangeLog()。
I've never done it, but my theory is you can use IMarkupContainer2::CreateChangeLog().