I am trying to find a way that tells me if a page has a vertical and horizontal scrollbars but no way is working.
I can't use jQuery.
This is what I done:
function hasVerticalScroll() {
return document.body.getBoundingClientRect().height >= window.innerHeight;
}
function hasHorizontalScroll() {
return document.body.getBoundingClientRect().width >= window.innerWidth;
}
I tested this code on a blank page without scrollbars and in a page with scrollbars and I get incorrect results (I get that there is a scrollbar on a page without a scrollbar for example).
Any idea?