Jquery 当有滚动条时,如何获得完整的窗口高度?

Jquery 当有滚动条时,如何获得完整的窗口高度?,jquery,Jquery,var window_height=$(window.height();这将给出当前窗口高度,而不是包括滚动高度在内的完整高度。我需要完整的窗口高度,包括滚动高度。使用: function getheight(){ var d= document.documentElement; var b= document.body; var who= d.offsetHeight? d: b ; return Math.max(who.scrollHeight,who.of

var window_height=$(window.height();这将给出当前窗口高度,而不是包括滚动高度在内的完整高度。我需要完整的窗口高度,包括滚动高度。

使用:

function getheight(){
    var d= document.documentElement;
    var b= document.body;
    var who= d.offsetHeight? d: b ;
    return Math.max(who.scrollHeight,who.offsetHeight);
}
getheight()

您应该检查此链接:

是的,这是

$("body").height()

以上这些都不适用于我——都给出了视口高度。我必须将整个页面包装在一个div(类“wrapper”)中,然后使用以下内容获取它:

    $('.wrapper').prop('scrollHeight');
使用
$(document).height()以获得可滚动区域的全高

使用
$(window.height()仅获取可视区域高度


重要提示:文档高度是整个文档的整个高度,甚至是可视区域之外的高度。窗口高度只是可视区域。

从2020年起,查找整个文档高度的最佳方法是:

document.documentElement.scrollHeight

信贷:关于另一个问题。

试试$('body').prop('scrollHeight')$(document.height();否-仅可见。我的一个部门要多得多。我想要所有在视野之内和之外的东西的总和。
document.documentElement.scrollHeight