最近开发用到这几个 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;
- }
来源: http://www.bubuko.com/infodetail-2631182.html