JavaScript : How to get the window width and height?

标签 javascript css internet-explorer browser resize

我想获取窗口的高度和宽度,包括地址栏、状态栏等...

如何获得如下图所示的窗口全高和全宽?

enter image description here

注意:我知道 window.innerHeightwindow.innerWidth 。它不适合这种情况。 window.innerHeight 仅用于获取 DOM 高度。outerWidth 也没有提供我想要的。

希望我们的堆栈用户能给出一个跨浏览器兼容的好的解决方案。

最佳答案

如果你不想使用滚动条等,可以使用它。:

window.innerHeight; // for height

window.innerWidth; // for width

在你的情况下,如果你想要它完整,请使用下面的。

window.outerHeight; // for height

window.outerWidth; // for width

关于JavaScript : How to get the window width and height?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22929402/

相关文章:

javascript - React JS Hamburger 菜单在单击菜单项后不会折叠回来

javascript - `add` 但具有 "mutating"属性,例如 `push`

javascript - 文本框的边框被另一个类覆盖

jquery - Bootstrap 菜单上的第三级悬停延迟

html - IE7、8、9 无法正确读取媒体查询。

javascript - 从模块导入解构

javascript - React-router导致无法读取未定义的属性 'listen'

javascript - 如何使用 jQuery(或类似的)来提取所有的 CSS

javascript - 如何确保为客户端加载最新版本的 javascript 代码?

html - Internet Explorer 中出现白色的简单网页