可能重复:
如何检测div元素中的溢出?
有没有一种跨浏览器的方式来监听div元素的溢出?
类似于:$('#myDiv').bind("divOverflow", function(){alert('div溢出了!')})
可能重复:
如何检测div元素中的溢出?
有没有一种跨浏览器的方式来监听div元素的溢出?
类似于:$('#myDiv').bind("divOverflow", function(){alert('div溢出了!')})
<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>
更多信息请参考:如何检测div元素中的溢出?
scrollHeight > offsetHeight
。这方面没有内置事件。