$(window).height() 返回奇怪的值
$(window).height() returns strange value
我尝试了以下命令来确定视口高度:
var H1 = document.documentElement.clientHeight,
H2 = $(window).height();
在所有情况下,结果均为 8。但是视口要大得多(> 500(。
补充:
区别在于
H = $(document).height()
H1 = $(window).height()
使用 Firefox-Browser (24.0/Debian(。H = 600 H1 = 8使用 铬 (29.0/Debian( H = 600 H1 = 600
我不知道为什么。
如果有边距或填充,您应该查看$(window).outerHeight()
.
更多信息在这里
请注意,.height(( 将始终返回内容高度,而不管 CSS box-ssize 属性的值如何。从 jQuery 1.8 开始,这可能需要检索 CSS 高度加 box-ssize 属性,然后在元素具有 box-ssize: border-box 时减去每个元素上的任何潜在边框和填充。要避免这种惩罚,请使用.css("height"(而不是.height((。
是否有边距和填充?
试试H2 = $(window).outerHeight(true)
相关文章:
- $(document).height和$(window).heaght都返回相同的值-使用的是正确的doctype
- $(window).height() inside iframe?
- document和window height返回相同的值
- window.screen.width和window.screen.height在iPad3上不起作用
- Ipad:window.height() 在 Safari 中给出不好的值,但在 Chrome 中没有
- 当屏幕 CSS 像素比大于 1 时,在不同的浏览器上获取相同的 window.screen.height 和 windo
- Android浏览器的screen.width,screen.height和window.innerWidth和wind
- jQuery 数学运算在 $(window).height() 上:如果减法不起作用,则除法不起作用
- $(window).height() 返回奇怪的值
- 如何应用 var height = $(window).height() - 20;到 .followTo() 函数
- 为什么 $(window).height() 和 $(document).height() 等价在 Firefox 中效
- window.height和document.height返回相同的值
- $(window).width()&$(window).height();在每个浏览器中都有不同的表现
- javascript:$(window).height不是函数
- 如何在1到100的范围内应用document.height/window.height的比率
- $(window).height()值在firefox22.0中是常量
- $(window).height()没有't动态更新
- Jquery $(window).height()和$(document).height()返回相同的结果
- $(window).height()的值和元素宽度在加载和文档就绪时都是错误的
- $(window).height()在IE10中不工作