J.R. wrote:
Thomas 'PointedEars' Lahn wrote:
J.R. wrote:
On 10/11/2011 12:09, David Mark wrote:
if (document.documentElement&& typeof
document.documentElement.clientWidth == 'number') {
var getInnerDimensions = function(el) {
return [el.clientHeight, el.clientWidth];
};
}
Considering an element having scrollbars, we might use:
return [el.scrollTop + el.clientHeight,
el.scrollLeft + el.clientWidth];
Please explain what the scroll position has to do with the element
dimensions.
[…]
A better approach would be using scrollWidth and scrollHeight, but these
properties are "buggy" in IE and Opera, according to
<
http://www.quirksmode.org/dom/w3c_cssom.html#elementview>. The irony
here is that scrollWidth and scrollHeight were introduced by Microsoft
in their MSIE's DHTML object model...
Therefore, if we want a "getInnerDimensions" function to return the
correct dimensions for the element's content we will need to add the
scrollTop and scrollLeft values to the clientHeight and clientWidth
values respectively, otherwise we would not get the correct inner
dimensions if the element is scrolled all the way down or to the right.
But what if the element doesn't have scrollbars? No problem, because
scrollTop and scrollLeft will return zero.
And if I scroll down or right a scrollable element its content becomes
higher/wider?