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;
}

猜你喜欢

转载自www.cnblogs.com/koala0521/p/9135752.html
今日推荐