Skip to content

Instantly share code, notes, and snippets.

@stefano-bortolotti
Created March 12, 2014 16:22
Show Gist options
  • Save stefano-bortolotti/9510470 to your computer and use it in GitHub Desktop.
Save stefano-bortolotti/9510470 to your computer and use it in GitHub Desktop.
Get Viewport dimensions
function _getViewportDimensions() {
var dEl = document.documentElement,
clientH = dEl['clientHeight'],
innerH = window['innerHeight'],
clientW = dEl['clientWidth'],
innerW = window['innerWidth'];
return {
height : ( clientH < innerH ) ? innerH : clientH,
width : ( clientW < innerW ) ? innerW : clientW
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment