当前位置: 移动技术网 > IT编程>开发语言>JavaScript > javascript兼容性(实例讲解)

javascript兼容性(实例讲解)

2017年12月12日  | 移动技术网IT编程  | 我要评论

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];
 }
} 

以上这篇javascript兼容性(实例讲解)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网