EN
JavaScript - get browser window width
2 points
In this article, we're going to have a look at how to get the window width with JavaScript.
Quick solution:
xxxxxxxxxx
1
2
<html>
3
<body>
4
<script>
5
6
function printWidth() {
7
console.log(window.innerWidth);
8
}
9
10
</script>
11
<button onclick="printWidth()">Print window width!</button>
12
</body>
13
</html>
Note:
window.innerWidth
returns internal window width - the area where web page is rendered.