Addeventlistener fallback for older IE

天大地大妈咪最大 提交于 2019-12-11 07:58:46

问题


I am trying to create a simple fallback function, which will make sure addeventlistener will work in IE versions older than 9.

So far i have this

if (!Element.prototype.addEventListener)
{ 
     Element.prototype.addEventListener =
           function(ev, fc)
            {
                xxx.attachEvent('on' + ev, fc);
            }
}

The problem is, that I don't know how to get the reference to the element to which the event is being attached to. (the xxx)

Any advice is appreciated.


回答1:


That's​​​​​​​​​​​​​​​​​ this.



来源:https://stackoverflow.com/questions/23043085/addeventlistener-fallback-for-older-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!