Skip to content

Instantly share code, notes, and snippets.

@bhrnd
Created April 22, 2014 14:56
Show Gist options
  • Save bhrnd/11182415 to your computer and use it in GitHub Desktop.
Save bhrnd/11182415 to your computer and use it in GitHub Desktop.
Javascript function to return current viewport height and width (Source: Andy Langton, http://andylangton.co.uk/blog/development/get-viewport-size-width-and-height-javascript)
function viewport() {
var e = window, a = 'inner';
if (!('innerWidth' in window )) {
a = 'client';
e = document.documentElement || document.body;
}
return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment