javascriptブラウザを跨ぐイベントハンドラ


もっと読む
var EventUtil = {
    //      
    addEventListener: function(element,type,handler){
         if(element.addEventListener){
                element.addEventListener(type,handler,false);
         }else if(element.attachEvent){
                //IE   
                element.attachEvent("on" + type,handler);
         }else{
                element["on" + type] = handler;  
         }
    },
    //      
    removeEventListener: function(element,type,handler){
          if(element.removeEventListener){
                 element.removeEventListener(type,handler,false);
          }else if(element.detachEvent){
                 //IE   
                 element.detachEvent("on" + type,handler);
          }else{
                 element["on" + type] = null;
    }
}