javascript在事件监听方面的兼容性小结
1,IE使用attachEvent/detachEvent方法来添加和删除事件监听器;w3c使用addEventListener/removeEventListener方法。 2,IE对其事件使用onevent的命名方式,而w3c的是event的命名方式。 3,IE事件监听器内使用的是一个全局的Ev
1,IE使用attachEvent/detachEvent方法来添加和删除事件监听器;w3c使用addEventListener/removeEventListener方法。 2,IE对其事件使用onevent的命名方式,而w3c的是event的命名方式。 3,IE事件监听器内使用的是一个全局的Ev
实现代码如下: function addEventSimple(obj,evt,fn) {if (obj.addEventListener)obj.addEventListener(evt,fn,false);else if (obj.attachEvent)obj.attachEvent('on'