I use the following code to determine the width of the browser client area for centuries, and it has become 100% with all browsers, including FF, Safari and various versions of IE. However, now that I have switched to a new monitor with widescreen resolution (1280x800), this code does not work in IE8. He reports that the client speed is 1024 !!!
Any ideas on how to get the right width of the client area?
function getClientWidth() { var v=0,d=document,w=window; if((!d.compatMode || d.compatMode == 'CSS1Compat') && !w.opera && d.documentElement && d.documentElement.clientWidth) {v=d.documentElement.clientWidth;} else if(d.body && d.body.clientWidth) {v=d.body.clientWidth;} else if(xDef(w.innerWidth,w.innerHeight,d.height)) { v=w.innerWidth; if(d.height>w.innerHeight) v-=16; } return v; }
source share