javascript跨浏览器事件处理程序

     var EventUtil = {
              
          addHandler : function(element,  type ,  handler){
               if (element.addEventListener){
                    element.addEventListener(type,  handler,  false);
               } else if ( element.attachEvent){
                    element.attachEvent("on" + type , handler)
               } else {
                    element["on" + type] = handler;
               }
          
          },
 
          removeHandler: function( element , type , handler){
               if ( element.removeElementListener) {
                    element.removeElementListener( type , handler , flase);
               } else if ( element.detachEvent) {
                    element.detachEvent ( "on" + type , handler)
               } else {
                    element["on" + type] = handler;
               }
          }
 
          
     }
 

你可能感兴趣的:(JavaScript)