$(window).height()与$(document).height [英] $(window).height() vs $(document).height

查看:156
本文介绍了$(window).height()与$(document).height的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的

$(window).height();

,并得到了类似的问题 此处

and got the similar question here

在我尝试的情况下

$(document).height();

似乎返回了正确的结果

窗口高度返回320

文档高度返回3552时!

while document height returns 3552!

我发现了也是问题

但是在我的情况下,经过几次ajax操作之后,我调用height函数时,窗口已经完全加载了

But in my case window already gets loaded completely as I am calling height function after few ajax operations

那么了解当前窗口高度的最佳方法是什么?

So what is the best way to know the height of the current window?

推荐答案

好吧,您似乎已经把他们俩都误认为了他们的所作所为.

Well you seem to have mistaken them both for what they do.

$(window).height()为您(浏览器)窗口的高度(即视口)的无单位像素值.对于Web浏览器,此处的视口是画布的可见部分(通常小于要渲染的文档).

$(window).height() gets you an unit-less pixel value of the height of the (browser) window aka viewport. With respect to the web browsers the viewport here is visible portion of the canvas(which often is smaller than the document being rendered).

$(document).height()返回要呈现的文档的高度的无单位像素值.但是,如果实际文档的身体高度小于视口高度,则它将返回视口高度.

$(document).height() returns an unit-less pixel value of the height of the document being rendered. However, if the actual document’s body height is less than the viewport height then it will return the viewport height instead.

希望这可以使事情变得简单.

这篇关于$(window).height()与$(document).height的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆