Skip to content

Instantly share code, notes, and snippets.

@bgaze
Forked from joshcarr/window-height-width.js
Last active September 2, 2019 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgaze/5c81b793c265b3b687ef38ddd9a032f2 to your computer and use it in GitHub Desktop.
Save bgaze/5c81b793c265b3b687ef38ddd9a032f2 to your computer and use it in GitHub Desktop.
[Vanilla JS] Get window dimensions
const windowSize = () => {
let body = document.getElementsByTagName('body')[0];
return {
width: window.innerWidth || document.documentElement.clientWidth || body.clientWidth,
height: window.innerHeight || document.documentElement.clientHeight || body.clientHeight
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment