Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / January 2005



Tip: Looking for answers? Try searching our database.

How to tell height of div where height is not set?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don Vaillancourt - 28 Jan 2005 02:02 GMT
Is there a way to determine the height of the following div.

<div style="width:200px;">
This is content.<br>
Inside a div that
will expand vertically
as more content is displayed.
</div>
Dietmar Meier - 28 Jan 2005 11:24 GMT
> Is there a way to determine the height of the following div.

In DOM compatible UAs, Element.offsetHeight is your friend.

ciao, dhgm
Richard Cornford - 28 Jan 2005 23:55 GMT
>> Is there a way to determine the height of the following div.
>
> In DOM compatible UAs, Element.offsetHeight is your friend.

It doesn't seem reasonable to describe a UA supporting offsetHeight as
'DOM compatible' as offsetHeight is a Microsoft proprietary property of
elements (introduced in IE 4) that has been adopted by other browsers
(and is very useful) and it is not part of current (Level 2) DOM
specifications. There is at least one DOM compatible (Level 1 in that
case) browser that does not implement any source of element size and
position information.

Richard.
Stanimir Stamenkov - 30 Jan 2005 17:53 GMT
/Richard Cornford/:

>>> Is there a way to determine the height of the following div.
>>
[quoted text clipped - 5 lines]
> (and is very useful) and it is not part of current (Level 2) DOM
> specifications.

Hm, isn't 'ViewCSS.getComputedStyle' part of the DOM Level 2 Style
specification, meant for just that? The core DOM interfaces aren't
meant to deal with visual presentation issues, anyway.

Signature

Stanimir

Richard Cornford - 30 Jan 2005 18:49 GMT
> /Richard Cornford/:
>>>
[quoted text clipped - 11 lines]
> specification, meant for just that? The core DOM interfaces aren't
> meant to deal with visual presentation issues, anyway.

And this is relevant to the use of offsetHeight because ... ?

Richard.
Stanimir Stamenkov - 30 Jan 2005 18:59 GMT
/Richard Cornford/:
>> /Richard Cornford/:
>>
[quoted text clipped - 9 lines]
>
> And this is relevant to the use of offsetHeight because ... ?

I was trying to make argument that obtaining the actual height of an
element is part of the DOM Level 2 (although no the core)
specification, but I was wrong. :-)

Signature

Stanimir

Richard Cornford - 30 Jan 2005 19:24 GMT
> /Richard Cornford/:
>>> /Richard Cornford/:
[quoted text clipped - 16 lines]
> an element is part of the DOM Level 2 (although no the core)
> specification, but I was wrong. :-)

So not relevant to the use of offsetHeight at all.  ;)

However, where supported (and tanking variations in implementations
(their completeness and the interpretation of the more ambiguous parts
of the DOM spec) into account) - getComputedStyle - can be used to
acquire information about the height of an element. But it is necessary
to understand how CSS relates to the absolute size of the resulting
element. For example, offsetHeight would include the borders of an
element, while CSS height would specify the height inside the borders
(by CSS specification), not including the (top and bottom) border
widths. Padding, margins, the various display property types, etc, need
to be taken into account when using computed styles to acquire position
and size information.

Richard.
Stanimir Stamenkov - 30 Jan 2005 18:55 GMT
/Stanimir Stamenkov/:
> /Richard Cornford/:
>
[quoted text clipped - 7 lines]
> specification, meant for just that? The core DOM interfaces aren't meant
> to deal with visual presentation issues, anyway.

My bad: the computed is not the same as the actual value
<http://www.w3.org/TR/1998/REC-CSS2-19980512/cascade.html#computed-value>.
But the second sentence still holds. The actual height would be
dependent on the specific style language/layout engine
implementation, which if not CSS based would use different
interfaces to that info.

Signature

Stanimir

Dietmar Meier - 31 Jan 2005 11:32 GMT
> offsetHeight is a Microsoft proprietary property
> of elements (introduced in IE 4) that has been adopted by other
> browsers

Whoa, yes.

ciao, dhgm
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.