JS获取客户端的窗口大小

function getClientSize() {
    var c = window,
    b = document,
    a = b.documentElement;
    if (c.innerHeight) {
        return {
            width: c.innerWidth,
            height: c.innerHeight
        }
    } else {
        if (a && a.clientHeight) {
            return {
                width: a.clientWidth,
                height: a.clientHeight
            }
        } else {
            return {
                width: b.body.clientWidth,
                height: b.body.clientHeight
            }
        }
    }
}

posted @ 2015-09-18 14:19  爱国学的程序员  阅读(474)  评论(0编辑  收藏  举报