1// better than using window.innerWidth / window.innerHeight
2// because of scrollbars
3const client = {
4 width: document.documentElement.clientWidth,
5 height: document.documentElement.clientHeight
6}
1var win = window,
2 doc = document,
3 docElem = doc.documentElement,
4 body = doc.getElementsByTagName('body')[0],
5 x = win.innerWidth || docElem.clientWidth || body.clientWidth,
6 y = win.innerHeight|| docElem.clientHeight|| body.clientHeight;
7alert(x + ' × ' + y);
1// Size of browser viewport.
2$(window).height();
3$(window).width();
4
5// Size of HTML document (same as pageHeight/pageWidth in screenshot).
6$(document).height();
7$(document).width();
1<p id="demo"></p>
2
3<script>
4document.getElementById("demo").innerHTML =
5"Screen width is " + screen.width;
6</script>