Skip to content

Instantly share code, notes, and snippets.

@jhafner
Created November 20, 2012 16:55
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 jhafner/4119231 to your computer and use it in GitHub Desktop.
Save jhafner/4119231 to your computer and use it in GitHub Desktop.
Cross-browser screen width/height polling
var x; // Screen Width
var y; // Screen Height
function screenSize(){
var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;
console.log('x: ' + x + 'px | y: ' + y + 'px');
}
screenSize();
$(window).resize(function(){
screenSize();
});
var x; // Screen Width
var y; // Screen Height
function screenSize(){
var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;
console.log('x: ' + x + 'px | y: ' + y + 'px');
}
screenSize();
$(window).resize(function(){
screenSize();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment