i need the innerHeight and innerWidth of the clients browser window to be returned from a function.
here is what i have however some times the value being returned is in fact greater than the browser window (only by a few pixles) i'm assuming this has something to do with 'tabs' in my browser.
Code:
function getW(){
var w;
if(document.innerWidth){ w=document.innerWidth;
} else if(document.documentElement.clientWidth){ w=document.documentElement.clientWidth;
} else if(document.body){ w=document.body.clientWidth; }
return w;
}
function getH(){
var h;
if(document.innerHeight){ h=document.innerHeight;
} else if(document.documentElement.clientHeight){ h=document.documentElement.clientHeight;
} else if(document.body){ h=document.body.clientHeight; }
return h;
}
Edit:
i'm returning the value into a Math.random()*getH();
i'm using the value from that to randomly position a single character on the page.
hope that helps :S