View Full Version : how to "getComputedStyle" in IE6
brothercake
02-21-2003, 11:34 PM
I want to find out the height of an inline list item. The CSS for it looks like this
ul.udm ul li {
float:left;
clear:both;
width:10em;
margin:0;
padding:0;
}
I'm inside a DHTML behavior (though not sure if this makes a difference) where the list-item object is "element". This is what I'm getting:
element.currentStyle.height // returns "auto"
and obviously
element.style.height // returns an empty string
but curiously
element.offsetHeight // returns 0
Any ideas?
Last ditch effort, try:
element.runtimeStyle.height
I wonder why offsetHeight is returning 0 though... perhaps the behavior is executed before the element even renders?
brothercake
02-22-2003, 01:55 AM
Originally posted by jkd
element.runtimeStyle.height
Empty string again :(
I've got an inkling about this though - it's inside a behaviour attached to <li/> at the top of a complex list - and so it cascades through all levels of <li/> in the structure.
The attached mouseover function contains this:
if(element.parentElement.className!="udm") {
alert(element.offsetHeight);
}
else {
alert(element.offsetHeight);
}
The classname discriminator distinguishes events in the main list from events in the nested lists. The else condition is the main list-items, and there it correctly returns the offset height; only the nested items return 0.
It's bubbling of some kind, isn't it? If I "cancelBubble" at the end of the function, it won't cascade and I'll get the right value back ... but ... then *the whole thing doesn't work* - events have to cascade, otherwise it's a dead duck.
Er ...
Jerome
03-16-2003, 12:35 PM
It's sunday, so don't blame me for this, did You try to extract - udm - from the others in Your CSS, like:
udm{
float:left;
clear:both;
width:10em;
margin:0;
padding:0;
}
ul.udm ul li {
float:left;
clear:both;
width:10em;
margin:0;
padding:0;
}
Or with ID, just so that it returns the value.
Jerome
brothercake
03-16-2003, 02:14 PM
Thanks for the suggestion, but that implies a predicatable heirarchy; if the heirarchy is predictable then the value could be calculated from other values.
But it isn't predictable, which is why I need the offsetHeight.
But no worries, I found a different solution a while ago, which basically involved not needing to know :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.