Skip to content

Instantly share code, notes, and snippets.

@Alex1990
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save Alex1990/4d1e23fe2440858acaee to your computer and use it in GitHub Desktop.

Select an option

Save Alex1990/4d1e23fe2440858acaee to your computer and use it in GitHub Desktop.
Get window(aka viewport) width and height.
/**
* Get window/viewport width and height. The window.innerWidth value includes the scrollbar,
* and document.documentElement.clientWidth/document.body.clientWidth doesn't include.
* Compatibility: IE6+ and other modern browsers
*/
function winW() {
return window.innerWidth || document.documentElement.clientWidth;
}
function winH() {
return window.innerHeight || document.documentElement.clientHeight;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment