FireFox 中的 clientHeight
我有一个 HTML 代码表格。
我需要使用 JavaScript 获取该表的高度,因此
alert(document.getElementById('myTable').clientHeight);
在 IE 中返回正确的值,但在 FF 中始终返回 0。
如何获取 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
MDC 说:
在 Firefox 中,
offsetHeight
属性包含当前像素元素的高度,因此您可以使用以下内容:MDC says:
In Firefox, the
offsetHeight
property contains the current pixel height of an element, so you can use something like:你尝试过offsetHeight吗?请参阅http://www.quirksmode.org/dom/w3c_cssom.html
Did you tried offsetHeight? See http://www.quirksmode.org/dom/w3c_cssom.html
clientHeight 在我的 Firefox 中工作: http://jsfiddle.net/sZ9eg/
clientHeight works in my Firefox: http://jsfiddle.net/sZ9eg/
也许 comeone 可以在这里纠正我,但是如果您想获取特定元素的高度,那么为什么不直接使用
EDIT:这仅在元素具有内联样式和定义的高度时才有效
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