Zo72
Zo72

Reputation: 15355

HTML Element: get notified when the scrollbar appears

I have a div like this:

<div id='test' style='overflow:auto'>
...
</div>

In JavaScript (no jQuery) how do I know when - as a consequence of the user resizing the browser - the div is showing a horizontal bar or not?

Note: I don't want only to figure if it is showing horizontal bar or not, I want to be notified when that happens.

Upvotes: 0

Views: 234

Answers (1)

hungryMind
hungryMind

Reputation: 7009

If you want to hook the resize of window

window.onresize = function(){
 var test = document.getElementById("test");
 if(test.offsetHeight != test.scrollHeight)
    // raise event or call ur method
}

Upvotes: 1

Related Questions