Tags: #js
It’s possible to analyze the viewport size in JavaScript but it’s a little messy:
Most browsers support window.innerWidth and window.innerHeight.
But IE6, 7, 8 and 9 in quirks mode require document.body.clientWidth and document.body.clientHeight.
All the main browsers support document.documentElement.clientWidth and document.documentElement.clientHeight but it’s inconsistent.
Either the window or document dimensions will be returned depending on the browser and mode.