PDA

View Full Version : detect whether there is a scrollbar with Javascript, possible?


jonirvine
01-26-2005, 07:04 PM
Hello all,

Wondered whether it was possible to detect whether or not a page is using a vertical scrollbar or not using JavaScript?

Thanks in advance.

Jon

n8thegreat
01-27-2005, 08:40 AM
try this

var vHeight = 0;
if (document.all) {
if (document.documentElement) {
vHeight = document.documentElement.clientHeight;
} else {
vHeight = document.body.clientHeight
}
} else {
vHeight = window.innerHeight;
}

if (document.body.offsetHeight > vHeight) {
//insert code for whatever happens
//when theres a scrollbar
}