Re: how to get the height of an element

by "Justin H." <justinh(at)whidbey.net>

 Date:  Thu, 29 Mar 2001 09:57:28 -0800
 To:  "HWG Style" <hwg-style(at)hwg.org>
 References:  inc
  todo: View Thread, Original
You have to ask for it like this:

document.defaultView.getComputedStyle(document.getElementById('myDiv'),
null).getPropertyValue('height');

As I understand it, you can only get left, top, right, bottom, width, height
and display from this and there may be some quirks.  The value is returned
in pixels - i.e., 19px.

It's a round about way, but if IE supports the defaultView object, you
should be able to apply this to IE6 also, depending on how much of the DOM 2
spec it honors.

No guarantees, warantees or intelligence implied by the previous statement.
Your mileage may vary.  etc, etc, etc...

Justin H.

----- Original Message -----
From: "Jason Blair" <jason(at)bcs-inc.com>
To: <hwg-style(at)hwg.org>
Sent: Thursday, March 29, 2001 9:30 AM
Subject: how to get the height of an element


> Hi everyone.  I'm new to the list, so sorry if this question has been
> asked previously.
>
> Does anyone know how to get the height of an element where its
> height hasn't been explicitly set?  This was possible in Netscape4
> browsers, but I can't seem to get it in Netscape6.  For example,
> in Netscape4 I could ask:
> document.layers[some_number].document.height,
> and it would return the height of that element (in my case a DIV tag).
> However, with Netscape6 the call:
> document.getElementById(some_id).style.height doesn't give a height
> because I have not explicitly set it (I can't).
>
> Thanks in advance, and sorry for the beginner question.
>
> jason
>

HWG hwg-style mailing list archives, maintained by Webmasters @ IWA