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!
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!
Share Improve this question edited Feb 18, 2011 at 13:47 Robert Koritnik 105k56 gold badges286 silver badges413 bronze badges asked Feb 18, 2011 at 13:39 ihorkoihorko 6,95526 gold badges80 silver badges123 bronze badges 2- Try offsetHeight or scrollHeight ... – Šime Vidas Commented Feb 18, 2011 at 13:46
- 1 Just tried, offsetHeight returns 0 and scrollHeight also retorns 0 in FF :( – ihorko Commented Feb 18, 2011 at 13:49
4 Answers
Reset to default 5MDC 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;
Did you tried offsetHeight? See http://www.quirksmode/dom/w3c_cssom.html
clientHeight works in my Firefox: http://jsfiddle/sZ9eg/
Maybe eone 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;