Posted By

lfatr on 02/16/10


Tagged


Versions (?)

CLIENTSIZE ( WIDTH & HEIGHT ) FOR ALL BROWERS


 / Published in: JavaScript
 

URL: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

  1. function alertSize() {
  2. var myWidth = 0, myHeight = 0;
  3. if( typeof( window.innerWidth ) == 'number' ) {
  4. //Non-IE
  5. myWidth = window.innerWidth;
  6. myHeight = window.innerHeight;
  7. } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  8. //IE 6+ in 'standards compliant mode'
  9. myWidth = document.documentElement.clientWidth;
  10. myHeight = document.documentElement.clientHeight;
  11. } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  12. //IE 4 compatible
  13. myWidth = document.body.clientWidth;
  14. myHeight = document.body.clientHeight;
  15. }
  16. window.alert( 'Width = ' + myWidth );
  17. window.alert( 'Height = ' + myHeight );
  18. }

Report this snippet  

You need to login to post a comment.