慕码人8056858
通常,您可以比较client[Height|Width]带着scroll[Height|Width]为了侦测到这个.。但是,当溢出可见时,值将是相同的。因此,检测例程必须说明这一点:// Determines if the passed element is overflowing its bounds,// either vertically or horizontally.// Will temporarily modify the "overflow" style to detect this// if necessary.function checkOverflow(el){
var curOverflow = el.style.overflow;
if ( !curOverflow || curOverflow === "visible" )
el.style.overflow = "hidden";
var isOverflowing = el.clientWidth
|| el.clientHeight
el.style.overflow = curOverflow;
return isOverflowing;}在FF3,FF40.0.2,IE6,Chrome 0.2.149.30中进行了测试。