JS 兼容大全

//获取浏览器可视区宽度
function getWidth() {
    if (window.innerWidth){
        return window.innerWidth;
    }
    else{
        if (document.compatMode == "CSS1Compat"){
            return document.documentElement.clientWidth;
        }
        else{
            return document.body.clientWidth;
        }
    }
}
//获取浏览器可视区高度
function getWidth() {
    if (window.innerHeight){
        return window.innerHeight;
    }
    else{
        if (document.compatMode == "CSS1Compat"){
            return document.documentElement.clientHeight;
        }
        else{
            return document.body.clientHeight;
        }
    }
}
//获取浏览器卷曲高度
function getscrollTop() {
    return document.documentElement.scrollTop || document.body.scrollTop;
}

 未完,待续…