Addeventlistener fallback for older IE

2019-08-07 20:24发布

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条回答
ゆ 、 Hurt°
2楼-- · 2019-08-07 21:07

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

查看更多
登录 后发表回答