We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

Corhol on 09/04/06


Tagged

javascript window detection


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

rchk


getBrowserWidth() by Cameron Adams


Published in: JavaScript 


  1. // getBrowserWidth() by Cameron Adams
  2. // http://www.themaninblue.com/experiment/ResolutionLayout/
  3. function getBrowserWidth ( ) {
  4. if ( window.innerWidth ) { return window.innerWidth; }
  5. else if ( document.documentElement && document.documentElement.clientWidth != 0 ) { return document.documentElement.clientWidth; }
  6. else if ( document.body ) { return document.body.clientWidth; }
  7. return 0;
  8. }

Report this snippet 

You need to login to post a comment.