你的位置:首页 > Java教程

[Java教程]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
            }
        }
    }
}