[thelist] clientHeight vs. offsetHeight
Duncan O'Neill
dbaxo at ihug.co.nz
Mon Jul 29 22:36:00 CDT 2002
Tom Dell'Aringa wrote:
> Heyo,
>
> Fiddling with a CSS layout. I know that NN6/Mozilla do not support
> clientHeight, they have offsetHeight. Problem is they are two
> different things. offsetHeight gives you the amount of pixels offset
> from the offsetParent (their words, not mine.)
>
> Anyway, what I want to do is to get the height in pixels of an
> element in NN6 and Mozilla. Is there a way to do this? I am coming up
> empty.
Tom,
these ideas may help - or not....
if you know the ID of an element, you can get it's height
like below. But from quick testing it only works if the
height is explicit and inline;
document.getElementById('IDname').getAttribute('height')
You can also try this;
document.getElementsByTagName('img').item(0).getAttribute('height')
e.g. you could use this to get an array of image
heights (not tested)
imgHeights = new Array();
for (var i=0;i<document.images.length;i++){
imgHeights[i]=document.getElementsByTagName('img').item(i).getAttribute('height');
}
getting properties out of stlyesheets becomes more involved.
Steven Champeon has written a helpful article about methods
of doing this here;
http://developer.apple.com/internet/javascript/styles.html
hth,
--
=====================================================
Duncan O'Neill
"Smith The Reporter"
http://homepages.ihug.co.nz/~dbaxo/urban_legend.htm
=====================================================
More information about the thelist
mailing list