Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript:如何获得窗口的宽度和高度?_Javascript_Css_Internet Explorer_Browser_Resize - Fatal编程技术网

JavaScript:如何获得窗口的宽度和高度?

JavaScript:如何获得窗口的宽度和高度?,javascript,css,internet-explorer,browser,resize,Javascript,Css,Internet Explorer,Browser,Resize,我想得到窗口的高度和宽度,包括地址栏,状态栏等 如何获得下图所示的窗口全高和全宽 注意:我知道窗口。innerHeight和窗口。innerWidth。它不适合这种情况窗口。innerHeight仅用于获取DOM高度。outerWidth也不能提供我想要的 希望我们的stack用户能够提供一个跨浏览器兼容性的好解决方案。如果您不想使用滚动条等,请使用此解决方案: window.innerHeight; // for height window.innerWidth; // for width

我想得到窗口的高度和宽度,包括地址栏,状态栏等

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

注意:我知道
窗口。innerHeight
窗口。innerWidth
。它不适合这种情况<代码>窗口。innerHeight仅用于获取
DOM
高度。
outerWidth
也不能提供我想要的


希望我们的stack用户能够提供一个跨浏览器兼容性的好解决方案。

如果您不想使用滚动条等,请使用此解决方案:

window.innerHeight; // for height

window.innerWidth; // for width
否则在你的情况下,如果你想要它完全,使用下面的

window.outerHeight; // for height

window.outerWidth; // for width
使用jQuery怎么样


Source

Jquery可以是一种解决方案。读这个答案
$(window).width();

$(window).height();