473,385 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Finding div height when defined in a stylesheet

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.heig ht 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.heig ht;

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
Jul 20 '05 #1
2 4632
nbaxley wrote:
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.heig ht 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.heig ht;


Just to let you know, it works in Moz and IE if you put the
style="height: 153px" directly into the <div>. I understand that might
not be what you want as it's bad style. Could you explain why you want
to read out the height in the first place? Maybe that would help in
figuring out a solution to the problem.
Jul 20 '05 #2
nbaxley wrote:
<div id="ModuleHeader"> <img src="photobugHEAD.jpg" width="572"
height="153"></div>

The attached stylesheet contains this defintion:

#ModuleHeader {
width: 100%;
height: 153px; [...] }

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


The style property refers to inline styles (i.e. contents of a style
attribute). You may try to traverse the CSS DOM.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alison Stewart | last post by:
A perennial problem; apologies if people are sick of this one. I have a dynamic-width page with stripes on the left and the right; the left stripe is defined in "body {background:}", while the...
8
by: Serge Hartmann | last post by:
hi there, I created two different backgrounds for the same page to obtain a (fake) left margin and a (true) right margin. -> left background, defined in body section, aligned bottom and with...
2
by: Marek Mänd | last post by:
I have simple structure like: <div> <h3 style="text-align:center;"> <span style="float:right;">input type="image"/></span> <span style="float:left;">input type="image"/></span> boxes titlebar...
12
by: Andy Jeffries | last post by:
Hi all, I want to write a function that given two elements will make their heights equal to the larger element. I've had a go at it and it works, but it makes both their heights larger than...
13
by: Haines Brown | last post by:
I have a style for a list: dl { line-height: 1; margin-bottom: 1em; } But the W3C CSS validator says: Line: 124 Context : dl Invalid number : line-height Parse Error -
14
by: rsearing | last post by:
I am new to HTML and will have to beg if this is obvious, but I am trying to design a table that looks like: ******************************** *----A------*------------------------*...
3
by: Arielle | last post by:
Problem: Using an XHTML doctype for all our pages, this is not optional. The layout the client wants to use requires the site to be "full screen" with a header, footer, horizontal menu, and main...
4
by: Christopera | last post by:
Hello, I have built a site that uses two divs, one verticle, and one horizontal as graphic style for the ite. The problem I am having is that if the browser is resized very small the divs are...
2
by: ssmeshack | last post by:
Hai all, Im having problem to set minimum height to <td> tag. It only takes height only not min-height. Im ie7 browser and developing web based system in Visual Web Deveploper 2008 (C# .Net). ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.