Sometimes, we want to get browser width using JavaScript code.
In this article, we’ll look at how to get browser width using JavaScript code.
How to get browser width using JavaScript code?
To get browser width using JavaScript code, we can use a few properties.
For instance, we write
const w = window.innerWidth;
const h = window.innerHeight;
const ow = window.outerWidth;
const oh = window.outerHeight;
to get the width in the browser window with window.innerWidth
.
And we get the width in the browser window plus the sidebars’ widths with window.outerWidth
.
Conclusion
To get browser width using JavaScript code, we can use a few properties.