javascript兼容性

时间:2017-08-14 19:54:48   收藏:0   阅读:211

1.事件冒泡:

//取消冒泡
 if(e.stopPropagation){
        e.stopPropagation();//w3c定义的APIbiaozhun
}else{
        e.cancelBubble=true;//兼容IE 6,7,8浏览器
}

2.获取某个元素的CSS属性值:

//获取某个元素的CSS属性值
function getStyle(element,stylename){
    if(element.currentStyle){
        //IE
        return element.currentStyle[stylename];
    }else{
        //其他浏览器
      var computedStyle=window.getComputedStyle(element,null);
       return computedStyle[stylename];
    }
} 

 

原文:http://www.cnblogs.com/nlj-blog/p/7359738.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!