最近開發用到這幾個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; }