问题
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.
回答1:
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?
来源:https://stackoverflow.com/questions/17976305/how-to-check-event-listeners-on-an-element-in-ie9