ihorko
ihorko

Reputation: 6945

clientHeight in FireFox

I have a table in HTML code.

I need to get height of that table using JavaScript, so

alert(document.getElementById('myTable').clientHeight);

returns a correct value in IE, but always returns 0 in FF.

How can I get the height of the table in Firefox?

Thanks!

Upvotes: 1

Views: 5426

Answers (4)

JamesHalsall
JamesHalsall

Reputation: 13485

Maybe comeone can correct me here, but if you want to get the height of a specific element then why not just use

EDIT: this only works if the element has inline styles and a defined height

document.getElementById('myReputation').style.height;

Upvotes: 0

Šime Vidas
Šime Vidas

Reputation: 185923

clientHeight works in my Firefox: http://jsfiddle.net/sZ9eg/

Upvotes: 1

Marcel Korpel
Marcel Korpel

Reputation: 21763

MDC says:

clientHeight is a non-standard, HTML-specific property introduced in the Internet Explorer object model.

In Firefox, the offsetHeight property contains the current pixel height of an element, so you can use something like:

var theHeight = element.clientHeight || element.offsetHeight;

Upvotes: 5

Daniel Steigerwald
Daniel Steigerwald

Reputation: 1101

Did you tried offsetHeight? See http://www.quirksmode.org/dom/w3c_cssom.html

Upvotes: 1

Related Questions