[removed] IE event.preventDefault is null or not an object

前端 未结 2 753
死守一世寂寞
死守一世寂寞 2020-12-21 16:17

My code works fine in FF/Chrome/Everything except IE(failed in both 7/8, didn\'t bother going furthur down). Due to restrictions, I cannot use jQuery and am hard-coding the

2条回答
  •  温柔的废话
    2020-12-21 16:32

    In IE the event object is not passed as the first argument to an event handler. Instead it is a global variable:

    function mousedown(e){
     var evt = e || window.event; // IE compatibility
     if(evt.preventDefault){  
      evt.preventDefault();  
     }else{  
      evt.returnValue = false;  
      evt.cancelBubble=true;  
     }
     //Processing   
    };
    

提交回复
热议问题