e.stopPropagation()兼容性处理


使用jquery库,e.stopPropagation()兼容所有。

原生的就要这么写

function stopPropagation(e){

    e=window.event||e;

    if(document.all){  //只有ie识别——————可能有误(document.all主要用来判断是否为ie浏览器)

        e.cancelBubble=true;

    }else{

        e.stopPropagation();

    }

}

 

//判断是否为IE

function isIE(){

  var userAgent = navigator.userAgent.toLowerCase();
  if(userAgent.indexOf("msie") >= 0 || userAgent.indexOf("trident") >= 0) return true;

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM