Forum Moderators: open

Message Too Old, No Replies

reading the 'real' height of an element

         

fuho

10:52 am on Aug 18, 2005 (gmt 0)

10+ Year Member



Hi there,
does anyone know how to get the REAL value of an element, for example DIV, after it was resized by its content?
How to get the value in Javascript. I need this for scrolling news, generated by PHP, and since I do not know the length of the news I can not 'hardcode' the height in CSS.(I can but it is overdriven, because the text is longer then the empty DIV would be)
Thanx in advance

RonPK

12:22 pm on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the element has an ID, try
document.getElementById("idHere").clientHeight

fuho

1:19 pm on Aug 18, 2005 (gmt 0)

10+ Year Member



Thank you very VERY much, I was looking for this information all over internet for the last four days!

This is somehow working, but the values I get are a bit strange, is the number in pixels?
Because the number is allways much bigger, then the expected height.

RonPK

1:34 pm on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's some documentation:

[msdn.microsoft.com...]
[mozilla.org...]

On second thoughts, offsetHeight may be more accurate:

document.getElementById("idHere").offsetHeight

Measuring heights is a rather messy task, especially when browser manufacturers start introducing their own definitions.

fuho

1:36 pm on Aug 18, 2005 (gmt 0)

10+ Year Member



I figured out that the number is exactly twice as big, now I am dividing it by two, and rounding.
And the scroller works just fine, but I still need something.
I am looking for some Javascript Ultimate reference, with every info I can think about, where would the whole DOM be described and how to access it and so on...
And it should be in downloadible form. So if Anyone Knows about something like that, please let me know.

RonPK

2:18 pm on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Javascript: Google for 'Client-Side JavaScript 1.3 Reference download'

DOM: there's a downloadable reference on mozilla.org.

RonPK

2:53 pm on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's a site [devedge-temp.mozilla.org] where you'll find a pointer to a downloadable javascript reference in HTML. You'll need the 1.3 reference because it is the latest one with the complete client-side information.

The javascript references used to reside at netscape, until some less intelligent life form took them offline.

fuho

4:01 pm on Aug 18, 2005 (gmt 0)

10+ Year Member



Thank you RonPK, your really helped me.