Get window width:
let width = window.innerWidth;
Try it Yourself »
let width = innerWidth;
Try it Yourself »
More examples below.
The innerWidth
property returns the width of a window's content area.
The innerWidth
property is read-only.
window.innerWidth
innerWidth
Type | Description |
A number | The the inner width of the browser window's content area in pixels. |
All height and width properties:
let text =
"<p>innerWidth: " + window.innerWidth + "</p>" +
"<p>innerHeight: " + window.innerHeight + "</p>" +
"<p>outerWidth: " + window.outerWidth + "</p>" +
"<p>outerHeight: " + window.outerHeight + "</p>";
Try it Yourself »
window.innerWidth
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!