javascript / jquery:如何获取内部窗口高度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3791049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 02:14:49  来源:igfitidea点击:

javascript / jquery: how do I get the inner window height?

javascriptjquery

提问by NullVoxPopuli

Like... the height that excludes the address bar, bookmarks, etc. just the viewing space.

比如……不包括地址栏、书签等的高度,只是查看空间。

$(window).innerHeight()

appears to not work.

似乎不起作用。

回答by Jonathan Lonowski

Use .height()for this, as mentioned in the API:

使用.height()了这一点,因为在API中提到:

This method is also able to find the height of the window and document.

$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document

此方法还可以找到窗口和文档的高度。

$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document

As for why .innerHeight()isn't working:

至于为什么.innerHeight()不起作用:

This method is not applicable to window and document objects; for these, use .height()instead.

此方法不适用于窗口和文档对象;对于这些,请.height()改用。