Skip to content

Instantly share code, notes, and snippets.

@imbcmdth
Created October 24, 2012 08:21
Show Gist options
  • Save imbcmdth/3944785 to your computer and use it in GitHub Desktop.
Save imbcmdth/3944785 to your computer and use it in GitHub Desktop.
var width = null;
var height = null;
window.onload = function () {
var windowSize = getSize();
width = windowSize['width'];
height = windowSize['height'];
window.onscroll = function(){ alert("Hello"); }
};
function getSize () {
var winW = 630, winH = 460;
if (document.body && document.body.offsetWidth) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetWidth ) {
winW = document.documentElement.offsetWidth;
winH = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
winW = window.innerWidth;
winH = window.innerHeight;
}
return {
'width': winW,
'height': winH
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment