getBrowserWidth() by Cameron Adams


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.