天天看點

js 判斷頁面是否存在滾動條

js 判斷頁面是否存在滾動條

hasScrollbar()傳回true:存在滾動條 | false:不存在滾動條
hasScrollbar() {
    return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight)
}