title: Detecting browser client area size on wide screen using javascript
body: <p>I've been using the following code to detect browser client area width for ages and it wokred 100% with all browsers, including FF, Safari and various versions of IE. However, now when I switched to a new monitor with widescreen resolution (1280x800) this code fails on IE8. It reports clientwidth of 1024 !!!???</p>
  
  <p>Any ideas how to get the correct client area width ?</p>
  
  <pre><code>function getClientWidth() {
    var v=0,d=document,w=window;
    if((!d.compatMode || d.compatMode == 'CSS1Compat') &amp;&amp; !w.opera &amp;&amp; d.documentElement &amp;&amp; d.documentElement.clientWidth)
      {v=d.documentElement.clientWidth;}
    else if(d.body &amp;&amp; d.body.clientWidth)
      {v=d.body.clientWidth;}
    else if(xDef(w.innerWidth,w.innerHeight,d.height)) {
      v=w.innerWidth;
      if(d.height&gt;w.innerHeight) v-=16;
    }
    return v;
  }
  </code></pre>