Skip to content

Instantly share code, notes, and snippets.

@Reder
Last active September 5, 2016 22:51
Show Gist options
  • Save Reder/145556 to your computer and use it in GitHub Desktop.
Save Reder/145556 to your computer and use it in GitHub Desktop.
Javascript to gt client width and height.
function getClient(e)
{
var h, w, de;
if (e) {
w = e.clientWidth;
h = e.clientHeight;
} else {
de = document.documentElement;
w = window.innerWidth || self.innerWidth
|| (de&&de.clientWidth) || document.body.clientWidth;
h = window.innerHeight || self.innerHeight
|| (de&&de.clientHeight) || document.body.clientHeight;
}
// test it.
// alert(h+":"+w);
return {w:w,h:h};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment