js关于可视区高度的一些运算

最近开发用到这几个API 记录一下


/*
* 获取浏览器窗口的总高度
*/ 
function getOffsetHeight(){
    return document.documentElement.offsetHeight || document.body.offsetHeight;
}

/*
* 获取浏览器窗口的可视区域的高度
*/ 
function getViewPortHeight() {
    return document.documentElement.clientHeight || document.body.clientHeight;
}
// 获取浏览器窗口垂直滚动条的位置
function getScrollTop() {
    return document.documentElement.scrollTop || document.body.scrollTop;
}


posted @ 2018-06-04 21:37  若水若鱼  阅读(424)  评论(0编辑  收藏  举报