页面总高度 [英] Total height of the page

查看:124
本文介绍了页面总高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JavaScript和jQuery获取页面的总高度,以便我可以检查页面是否足够长以显示某些内容,但是在我的测试中,我无法获得页面的总高度。

I'm trying to get the total height of a page using JavaScript and jQuery so I can check if the page is long enough to display something, however in my testing I am unable to get the total height of a page.

我在互联网上环顾四周,但这样的事情似乎没有很好的记录,因为我能找到的只是 scrollHeight ,正如我可能提到的,它不起作用。

I've looked around on the Internet but things like this don't seem to be well documented, as all I can find is scrollHeight, which, as I might mention, doesn't work.

任何使用jQuery查找它的方法吗?

Any way to use jQuery to find it?

推荐答案

框架:

var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
var _docWidth = (document.width !== undefined) ? document.width : document.body.offsetWidth;

这篇关于页面总高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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