⊗jsSpMWSz 24 of 294 menu

Window dimensions in JavaScript

The following properties contain the dimensions of the browser window that don't include the scrollbar:

let w = document.documentElement.clientWidth; // a width let h = document.documentElement.clientHeight; // a height

The following properties include the scrollbar:

let w = window.innerWidth; // a width let h = window.innerHeight; // a height

The difference between the two property types gives the size of the scrollbar:

let w1 = document.documentElement.clientWidth; let w2 = window.innerWidth; console.log(w2 - w1);

On button click, display the width and height of the window.

On button click, check if the window has vertical scrolling.

On button click, check if the window has horizontal scrolling.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline