var EventUtil = { addHandler : function(element,type,handler){ if (element.addEventListener)//标准 { element.addEventListener(type,handler,false); }else if (element.attachEvent)//老IE { //handler,必须保证this指向调用的对象,因为在IE下指向window element.attachEvent('on'+type,handler); }else { element['on'+type] = handler; } }, removeHandler : function(element,type,handler){ if (element.removeEventListener) { element.removeEventListener(type,handler,false); }else if (element.detachEvent) { element.detachEvent('on'+type,handler); }else { element['on'+type] = null; } } }