faqts : Computers : Programming : Languages : JavaScript : DHTML : DOM

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

57 of 61 people (93%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

Detecting height of dynamic elements in NN6

Jan 18th, 2001 15:39
Ian Grant, Jan Willem Boer,


When an elements style height property is read, this property returns 
the height as it is described in the HTML page. To get the real height 
of the element, IE uses element.offsetHeight. 
In NN6 this property can also be used:
  realheight = document.getElementsByTagName('div')[0].offsetHeight;
Another way of getting the real height is:
  test = document.getElementsByTagName('div')[0];
  realheight = document.defaultView.getComputedStyle
(test, "").getPropertyValue("height");
The function getComputedStyle() is documented in the W3C DOM 
recommendation http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-
20001113/css.html#CSS-ViewCSS, so i think this is the official way to 
do it. However, it is not supported in IE5.
It is also possible to use getElementById('myId') in place of 
getElementsByTagName('div')[0].