如何检查IE9中元素的事件监听器 [英] How to check event Listeners on an element in IE9

查看:83
本文介绍了如何检查IE9中元素的事件监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面在表格中有一些td元素,用户可以单击并拖动以重新排序。该页面使用原型构建。除了IE9之外的一切,这都有效,但在IE9中,当我尝试单击并拖动时,我只是突出显示页面上的一些内容。我怀疑处理程序实际上并没有附加到td元素。



有没有办法检查哪些监听器附加到IE9中的元素?



(代码也不在我可以分享的地方,这就是我没有发布任何内容的原因。)



<编辑:事实证明我实际上正在使用原型1.6.1,问题最终是由于不知道IE9和IE10不如< 9.这将是一个比我想象的更大的修复。

解决方案

最新的PrototypeJS(1.7.1)存储事件事件缓存中的观察者



例如,一个带有mydiv的< div>

 < div id =mydiv>< / div> 

通过 observe() on()这样的方法

  $('mydiv ')。observe('click',function(){
alert('Click Happened');
});

事件缓存的点击属性将设置如下

  Event.cache [$('mydiv')._ prototypeUID] .click 

然而,这可能不是您问题的根源,因为您说它在除IE9之外的所有其他浏览器中工作 - 是否有一种方法可以提取一些代码并将其放入JSFiddle中然后发布链接?


I have a page that has some td elements in a table that the user can click and drag to reorder. The page is built using prototype. In everything but IE9, this works, but in IE9, when i try to click and drag, I just highlight some of the things on the page. My suspicion is that the handler isn't actually attaching to the td element.

Is there a way to check what listeners are attached to an element in IE9?

(The code is also not in a place that I can share it, which is why I have not posted any.)

Edit: It turns out I was actually using prototype 1.6.1, and the problem was ultimately caused by that not knowing that IE9 and IE10 are less awful than < 9. It's going to be a much bigger fix than I thought.

解决方案

The latest PrototypeJS (1.7.1) stores the event observers in an Event Cache

So for example a <div> with id 'mydiv'

<div id="mydiv"></div>

After you create an observer via the observe() or on() methods like this

$('mydiv').observe('click',function(){
    alert('Click Happened');
});

The click property of the Event cache will be set like below

Event.cache[$('mydiv')._prototypeUID].click

However this might not be the source of your problem as you said it is working in all other browsers except IE9 - is there a way you can extract some of the code and put it into a JSFiddle and then post the link?

这篇关于如何检查IE9中元素的事件监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆