1

I have a div with overflow: auto (a vertical scroll bar appears if the div contains a lot info).

How could I identify at some point if the vertical scroll bar appears or not ?

Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
  • Sorry, can you maybe expand on that a bit. Do you mean use javascript to detect when the scroll bar appears and if so trigger an event? – Stuart Burrows Dec 16 '10 at 10:48
  • 1
    possible duplicate of [How to determine from Javascript if an html element has overflowing content](http://stackoverflow.com/questions/143815/how-to-determine-from-javascript-if-an-html-element-has-overflowing-content) – Adam Kiss Dec 16 '10 at 10:53

2 Answers2

3

From http://bytes.com/topic/javascript/answers/157924-detect-if-scrollbars-visible-inside-div:

if (document.getElementById('divID').scrollHeight > document.getElementById('divID').clientHeight)
{
//a vertical scroll bar is present
}
else
{
//a vertical scroll bar is NOT present
}
sje397
  • 41,293
  • 8
  • 87
  • 103
1

It's been answered here

Community
  • 1
  • 1
Saeb Amini
  • 23,054
  • 9
  • 78
  • 76