3

Possible Duplicate:
How to detect overflow in div element?

Is there a cross-browser way to listen to div overflow?

Something like: $('#myDiv').bind("divOverflow", function(){alert('div overflowed!')})

Community
  • 1
  • 1
fortuneRice
  • 4,214
  • 11
  • 43
  • 58

2 Answers2

2

You can do that by comparing scrollHeight with clientHeight.

<script type="text/javascript">
function GetContainerSize ()
{
    var container = document.getElementById ("tempDiv");
    var message = "The width of the contents with padding: " + container.scrollWidth + "px.\n";
    message += "The height of the contents with padding: " + container.scrollHeight + "px.\n";

    alert (message);
}
</script>

For more info: How to detect overflow in div element?

Community
  • 1
  • 1
Adam Plocher
  • 13,994
  • 6
  • 46
  • 79
0

You could set an interval and check if the element's scrollHeight > offsetHeight. There is no built-in event for this.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592