View Single Post
  #2 (permalink)  
Old 04-15-2008, 06:03 AM
velhari velhari is offline
D-Web Programmer
 
Join Date: Mar 2007
Location: Chennai
Posts: 67
velhari is on a distinguished road
Send a message via AIM to velhari
Thumbs up Re: get the information of the browser?

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}
}
__________________
Regards,
VELHARI
I am not totally useless. I can be used for a bad example
Reply With Quote