question about style.height

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • datactrl

    #1

    question about style.height

    Hi, all

    If I didn't set the height of an html element on a web page with html
    attributes. Then obj.style.heigh t always reports "0" even after the page has
    completely rendered. Is there any way to get the actual height after being
    rendered?

    Jack


  • Ron

    #2
    Re: question about style.height

    datactrl wrote:
    [color=blue]
    >Hi, all
    >
    >If I didn't set the height of an html element on a web page with html
    >attributes. Then obj.style.heigh t always reports "0" even after the page has
    >completely rendered. Is there any way to get the actual height after being
    >rendered?
    >
    >Jack
    >
    >
    >
    >[/color]
    The following code will get the computed height in pixels:

    var obj = document.getEle mentById("myObj ect");
    var objHeight = null;
    if(document.imp lementation.has Feature("CSS", "2.0")) {
    objHeight = document.defaul tView.getComput edStyle(obj,
    null).getProper tyCSSValue("hei ght").getFloatV alue(5);
    }
    else if(obj.clientHe ight!=null) {
    objHeight = obj.offsetHeigh t;
    }

    Learn more about the W3C CSS interfaces at
    http://www.w3.org/TR/DOM-Level-2-Style . IE's offsetHeight property was
    found at
    http://msdn.microsoft.com/workshop/a...fsetheight.asp
    ..

    Comment

    Working...