1 var eventUtil={ 2 addHandler:function(element,type,handler){ 3 if(element.addEventListener){//Dom2级事件处理程序 4 element.addEventListener(type,handler,false); 5 }else if(element.attachEvent){//IE事件处理程序 6 element.attachEvent("on"+type,handler); 7 }else{ 8 element["on"+type];//Dom0级事件处理程序 9 } 10 }, 11 removeHandler:function(element,type,handler){ 12 if(element.removeEventListener){ 13 element.removeEventListener(type,handler,false); 14 }else if(element.attachEvent){ 15 element.detachEvent("on"+type,handler); 16 }else{ 17 element["on"+type]=null; 18 } 19 } 20 };