how can i detect the height of a TD tag?

K

kaeli

And on the day 7 Oct 2003 11:44:38 -0700, (e-mail address removed) enlightened
us with said:
Is there a way to detect the height of a TD tag?

In recent browsers only, you can get the height of a table CELL (not a
tag - tags don't have a height).

Given the following cell:
<td id="whatever">...</td>

<script type="text/javascript">
myVar = document.getElementById?document.getElementById
("whatever").getAttribute("height"):0;
</script>

Browsers (older ones, like NN4) that do not support
document.getElementById would get 0 as the value.


--------------------------------------------------
~kaeli~
Kill one man and you are a murderer. Kill millions
and you are a conqueror. Kill everyone and you
are God.
http://www.ipwebdesign.net/wildAtHeart/
http://www.ipwebdesign.net/kaelisSpace/
------------------------------------------------
 
D

DU

kaeli said:
And on the day 7 Oct 2003 11:44:38 -0700, (e-mail address removed) enlightened



In recent browsers only, you can get the height of a table CELL (not a
tag - tags don't have a height).

Given the following cell:
<td id="whatever">...</td>

<script type="text/javascript">
myVar = document.getElementById?document.getElementById
("whatever").getAttribute("height"):0;
</script>

but here, there is no height attribute defined for the "whatever" cell,
so myVar will hold null. Height is not a valid attribute in strict DTD
anyway.

OTOH, document.getElementById("whatever").offsetHeight will return the
general pixel height of the cell.

Tested and working in Opera 7.20, Mozilla 1.5RC2, MSIE 6 and NS 7.1.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunclear/Netscape7/Netscape7Section.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top