facebook twitter youtube
in JavaScripts - 05 Sep, 2010, This Tutorial Has Been Viewed 11,787 Times.
by admin - no comments
Get browser window size using javascript
VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)

Very easy to get the browser window size using javascript, grab the code here

<script type="text/javascript" >
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
</script>
<input type="button" value="check" onClick="getBroWinSize()"/>
VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)
Get browser window size using javascript, 10.0 out of 10 based on 1 rating

Incoming search terms:




coded by nessus

Leave a Reply

Close
Please support the site
By clicking any of these buttons you help our site to get better