Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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-22-2003 at 12:39 AM.

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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?

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 03:01 AM.

  • #4
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Last edited by brothercake; 03-16-2003 at 03:18 PM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •