I was wondering if anyone knows how to check to see if the content in an iframe is overflowing and the scrollbars are visible?
Thanks
You want to check if the element's scrollHeight is greater than the clientHeight , or if the element's scrollWidth is greater than the clientWidth . This can be done with those properties directly, or by using helper methods provided by jQuery.
Content that is presented in an iFrame appears with a vertical scrollbar if the length of the child document exceeds the height of the iFrame and with a horizontal scrollbar if the child document elements won't wrap to the width of the iFrame.
in general you should compare the delta of the element's scrollHeight/scrollWidth and offsetHeight/offsetWidth. if positive then 'we got a winner'. but.. when looking for scrollbars in an iframe, things get a little bit trickier:
var frm=document.getElementById("frm");
var iIsVrScrollBar = frm.contentWindow.document.documentElement.scrollHeight>frm.contentWindow.document.documentElement.offsetHeight ? 1 : 0;
var iIsHrScrollBar = frm.contentWindow.document.documentElement.scrollWidth>frm.contentWindow.document.documentElement.offsetWidth ? 1 : 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With