js判断是否有滚动条

2025-05-06 19:51:21
推荐回答(2个)
回答1:

if (document.documentElement.clientHeight < document.documentElement.offsetHeight-4) //减4是因为浏览器的边框是2像素, 否则会一直判断有滚动条 
{
    alert('有滚动条');  
}
else
{
    alert('没有'); 
}

回答2: