首页 > 其他 > 详细

处理浏览器兼容你最喜欢用哪种方式

时间:2017-02-26 21:27:48      阅读:205      评论:0      收藏:0      [点我收藏+]
<script type="text/javascript">
通过这个盒子的属性名来获取属性值(条件是兼容所有浏览器)
    //var oDiv = document.getElementById("oDiv");
    /*function getCss(curEle,attr) {
        var val = null;
        try {
            val = window.getComputedStyle(curEle,null)[attr];
        }catch (e){
            val = curEle.currentStyle[attr];
        }
        return  val;
    }
    console.log(getCss(oDiv,"width"));*/
    /*function getCss(curEle,attr) {
        var val = null;
        if ("getComputedStyle" in window){
            val = window.getComputedStyle(curEle,null)[attr];
        }else {
            val = curEle.currentStyle[attr];
        }
        return  val;
    }
    console.log(getCss(oDiv,"width"));*/
    /*function getCss(curEle,attr){
        var val = null;
        if (window.getComputedStyle){
            val = window.getComputedStyle(curEle,null)[attr];
        }else {
            val = curEle.currentStyle[attr];
        }
        return val;
    }
    console.log(getCss(oDiv,"width"));*/
    /*function getCss(curEle,attr){
        var val = null;
        if (/MSIE (6|7|8)/.test(window.navigator.userAgent)){
            val = curEle.currentStyle[attr];
        }else {
            val = window.getComputedStyle(curEle,null)[attr];
        }
        return val;
    }
    console.log(getCss(oDiv,"width"));*/
</script>


处理浏览器兼容你最喜欢用哪种方式

原文:http://11415078.blog.51cto.com/11405078/1901350

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!