为什么在 TWebBrowser 中从未调用 ommouseenter 事件(已安装 IE9)
我想处理 ommouseenter 事件,但事件从未从 TWebBrowser 调用。虽然我成功捕获了 onmousemove 事件。当前浏览器IE9。我的代码:
var
D3: IHTMLDocument3;
begin
if Supports(WebBrowser1.Document, IHTMLDocument3, D3) then
begin
eo1 := TEventObject.Create(self.EventHadler);
D3.attachEvent('onmouseenter', eo1);
end;
end;
I want to handle ommouseenter event, but event never called from TWebBrowser. Although I successfully catch onmousemove event. Current Browser IE9. My code:
var
D3: IHTMLDocument3;
begin
if Supports(WebBrowser1.Document, IHTMLDocument3, D3) then
begin
eo1 := TEventObject.Create(self.EventHadler);
D3.attachEvent('onmouseenter', eo1);
end;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜想原因是 ommouseenter 事件 不起泡。 IOW,仅当鼠标指针移动到您附加事件的元素上时,它才会触发。因此,您不能使用一个“通用”事件处理程序,您必须附加到您所输入的每个元素。
I quess that the reason is that ommouseenter event does not bubble. IOW it only fires when the mouse pointer moves over the element you attached the event to. So you can't use one "generic" eventhandler, you have to attach to each and every element youre instred in.
您必须将事件处理程序附加到每个感兴趣的元素。如果您对所有元素感兴趣,那么您必须循环遍历所有元素:
因此,在理想的情况下,您将在收到感兴趣文档的
DocumentComplete
后附加处理程序,并在BeforeNavigate< 中再次分离/代码>。
但您应该注意,可能存在几个问题:
DocumentComplete
),因此您的事件处理程序永远不会被附加,FRAMEs
/IFRAMEs
并附上 我也希望它能像你的方法一样简单。这样我们就可以省去很多麻烦。
You have to attach the event handler to every element of interest. If you are interested in all elements then you have to loop through all elements:
So in an ideal world you would attach the handler after receiving
DocumentComplete
for the document of interest and detach again inBeforeNavigate
.There can be several problems though you should be aware of:
DocumentComplete
) thus your event handlers would never be attachedFRAMEs
/IFRAMEs
and attach the handlers thereI also wish it would be as easy as your approach. This would save us a lot of this hassle.
正如 ain 所指出的,
onmouseenter
不会冒泡,而是作为 MSDN 说,因此,您可以使用 onmouseover:
As ain has pointed out,
onmouseenter
does not bubble, but as MSDN says,So you can use onmouseover: