Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-21-2003, 11:34 PM   PM User | #1
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
how to "getComputedStyle" in IE6

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 edited by brothercake; 02-21-2003 at 11:39 PM..
brothercake is offline   Reply With Quote
Old 02-22-2003, 01:32 AM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
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?
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 02-22-2003, 01:55 AM   PM User | #3
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
Quote:
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:
Code:
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 ...

Last edited by brothercake; 02-22-2003 at 02:01 AM..
brothercake is offline   Reply With Quote
Old 03-16-2003, 12:35 PM   PM User | #4
Jerome
Regular Coder

 
Join Date: Oct 2002
Posts: 299
Thanks: 0
Thanked 0 Times in 0 Posts
Jerome is an unknown quantity at this point
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
Jerome is offline   Reply With Quote
Old 03-16-2003, 02:14 PM   PM User | #5
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
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
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

Last edited by brothercake; 03-16-2003 at 02:18 PM..
brothercake is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:49 PM.


Advertisement
Log in to turn off these ads.