Created
January 18, 2012 20:46
-
-
Save THEtheChad/1635495 to your computer and use it in GitHub Desktop.
Cross browser function to identify viewport size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function viewport(){ | |
var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0]; | |
// Standards compliant browsers (mozilla/netscape/opera/IE7): window.innerWidth & window.innerHeight | |
// IE6 in standards compliant mode: documentElement.clientWidth & documentElement.clientHeight | |
// Older IE6 | |
// document.getElementsByTagName('body')[0].clientWidth & | |
// document.getElementsByTagName('body')[0].clientHeight | |
return { | |
x: w.innerWidth||e.clientWidth||g.clientWidth, | |
y: w.innerHeight||e.clientHeight||g.clientHeight | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment