1const heightOutput = document.querySelector('#height');
2const widthOutput = document.querySelector('#width');
3
4function reportWindowSize() {
5 heightOutput.textContent = window.innerHeight;
6 widthOutput.textContent = window.innerWidth;
7}
8
9window.onresize = reportWindowSize;
1<p>Resize the browser window to fire the <code>resize</code> event.</p>
2<p>Window height: <span id="height"></span></p>
3<p>Window width: <span id="width"></span></p>