Get the Browser Window Size
-----------------------------------
window.innerHeight / window.innerWidth -
Works in Most browsers, Not in IE
document.body.clientHeight / document.body.clientWidth -
Works in Most browsers, Including IE
document.documentElement.clientHeight / document.documentElement.clientWidth -
Works in all DOM browsers, Including IE
By using the above properties, The value given by the browsers depends on the
document type declaration(DTD) triggers the browser's strict mode or quirks mode.
So, you can use the following script to get the browser size
Code:
function getBrowserSize() {
var Width = 0, Height = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
Width = window.innerWidth;
Height = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
Width = document.documentElement.clientWidth;
Height = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
Width = document.body.clientWidth;
Height = document.body.clientHeight;
}
return {"width":Width,"height":Height}
}