How to get Browser Window Size?
function getBroWinSize() {
var objDocEle = document.documentElement;
var objDocBdy = document.body;
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
else if(objDocEle &&(objDocEle.clientWidth || objDocEle.clientHeight)) { //IE 6+
myWidth = objDocEle.clientWidth;
myHeight = objDocEle.clientHeight;
}
else if(objDocBdy &&(objDocBdy.clientWidth || objDocBdy.clientHeight)){ //IE 4
myWidth = objDocBdy.clientWidth;
myHeight = objDocBdy.clientHeight;
}
window.alert( 'Width = ' + myWidth );
window.alert( 'Height = ' + myHeight );
}//getBroWinSize
No comments:
Post a Comment