Finding div height when defined in a stylesheet

Giganews Newsgroups
Subject: Finding div height when defined in a stylesheet
Posted by:  grou…@baxleys.org (nbaxley)
Date: 10 Nov 2003

I'm trying to detemine the height of a div in javascript.  The actual
height is defined in the attached stylesheet.  When I query
document.getElementById("ModuleHeader").style.height I get undefined.
Here's a bit of the code:
<div id="ModuleHeader"> <img src="photobugHEAD.jpg" width="572"
height="153"></div>

The attached stylesheet contains this defintion:

#ModuleHeader {
    width: 100%;
    height: 153px;
    position: relative;
    top: 0px;
    left: 0px;
    z-index: 20;
    text-align: left;
    background-color: #33CCCC;
}

But this javascript returns undefined:
document.getElementById('ModuleHeader').style.height;

How can I get that to return 153?  I don't want to rely on the height
of the image, which in this case happens to be the same height as the
div.

Thanks,
Nate Baxley

Replies