Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE vs Other browser offsetHeight and scrollHeight

So I have a resize handler that resizes some column headers depending on if there is a scroll on the right or not (overflow vs not overflow) to adjust the spacing to account for the scroll. The resize works when I'm changing the size of the frame to make the frame overflow vs not overflow. However when I'm modifying the columns in some way that doesn't affect the frame size, I still need the resize but the resize will bug out. Heres the pseudo code I have of a snippet of the resize.

if (display != "none") {
    if (frame.offsetHeight >= frame.scrollHeight) {
        display = "none"
    }
} else {
    if (frame.offsetHeight < frame.scrollHeight) {
        display = ""
    }
}

So the problem is that, when the resize handler is called when the frame size is not changed, in FF, Chrome and Safari, the scrollHeight is 1 more than frame.offsetHeight (ie. if offsetHeight is 100px, scrollHeight is actually 101px) but in IE, the offsetHeight and scrollHeight are the same, thus making the condition when display == "" and frame.offsetHeight < frame.scrollHeight to fail. Are these properties for IE and other browsers handled differently?

like image 418
Jason Hu Avatar asked Mar 23 '26 04:03

Jason Hu


1 Answers

Have you tried doing frame.contentWindow.document.body.offsetHeight to get the height? The height of the content, rather than the iFrame tag will work better for this.

like image 191
David Bradshaw Avatar answered Mar 25 '26 16:03

David Bradshaw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!