zoukankan      html  css  js  c++  java
  • JS浏览器兼容问题

    解决浏览器兼容问题

    获取事件对象兼容

          oBtn.onclick=function(eve){
            var e = eve ||window.event
            }
    

    获取事件目标兼容

          oBtn.onclick=function(eve){
            var e = eve ||window.evente.target
            var target =e.target ||window.event
        }
    

    阻止冒泡兼容

        function stopBubble(e){
            if(e.stopPropgation){
                e.stopPropgation();
            }else{
                e.cancelBubble=true;
            }
        }
    

    阻止系统自带功能

       function preDef(e){
            if(e.preventDefault){
                e.preventDefault();
            }else{
                e.returnValue==false;
            }
        }
    

    键码兼容

     var which = e.keyCode || e.which;
    

    字符码兼容

    var which = e.charCode || e.which;
    
    请用今天的努力,让明天没有遗憾。
  • 相关阅读:
    js的元素对象
    js实现在末尾添加节点
    js实现点击增加文本输入框
    js的DOM对象
    js其它
    js实现99乘法表
    js
    http的六种请求方法
    11.进制
    10.Debug
  • 原文地址:https://www.cnblogs.com/cupid10/p/13179046.html
Copyright © 2011-2022 走看看