javaScript之跨浏览器的事件对象

    

    跨浏览器的兼容代码

var eventHandler = {
     addHandler: function(element, type, handler){},
     removeHandler: function(element, type, handler){},
     getEvent: function(event){
       return event ? event : window.event;
    },
   preventDefault: function(event){
      if(event.preventDefault){
      event.preventDefault();
  }else{
     event.returnValue = false;
 }
},
  stopPropagation: function(event){
     if(event.stopPropagation){
     event.stopPropagation();
}else{
    event.cancelBubble = true;
   }
  }
};

 

posted on 2017-06-20 22:15  公子小苏  阅读(188)  评论(0编辑  收藏  举报