处理浏览器兼容你最喜欢用哪种方式
<scripttype="text/javascript">通过这个盒子的属性名来获取属性值(条件是兼容所有浏览器)//varoDiv=document.getElementById("oDiv");/*functiongetCss(curEle,attr){varval=null;try{val=window.getComputedStyle(curEle,null)[attr];}catch(e){val=curEle.currentStyle[attr];}returnval;}console.log(getCss(oDiv,"width"));*//*functiongetCss(curEle,attr){varval=null;if("getComputedStyle"inwindow){val=window.getComputedStyle(curEle,null)[attr];}else{val=curEle.currentStyle[attr];}returnval;}console.log(getCss(oDiv,"width"));*//*functiongetCss(curEle,attr){varval=null;if(window.getComputedStyle){val=window.getComputedStyle(curEle,null)[attr];}else{val=curEle.currentStyle[attr];}returnval;}console.log(getCss(oDiv,"width"));*//*functiongetCss(curEle,attr){varval=null;if(/MSIE(6|7|8)/.test(window.navigator.userAgent)){val=curEle.currentStyle[attr];}else{val=window.getComputedStyle(curEle,null)[attr];}returnval;}console.log(getCss(oDiv,"width"));*/</script>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。