在整个body窗体中.document.body.offsetWidth 比 document.body.clientWidth 多出一点儿偏移.我理解的是滚动条的宽度吧(你看右边的滚动条,在滚动条以内的就是document.body.clientWidth,加上两边的滚动条(当然有可能没有出现,如左边的),就是document.body.offsetWidth) 

解决方案 »

  1.   

    clientWidth Property
    --------------------------------------------------------------------------------
    Retrieves the width of the object including padding, but not including margin, border, or scroll bar.offsetWidth Property
    --------------------------------------------------------------------------------
    Retrieves the width of the object relative to the layout or coordinate parentexample:
    <DIV ID=oDiv STYLE="overflow:scroll; width:200; height:100">This example shows the difference between
    the dimension retrieved by the <B>clientWidth</B> and the dimension retrieved by the <B>offsetWidth</B>, the latter
    including the width of scrollbars.</DIV>
    <BUTTON onclick="alert(oDiv.clientWidth)">client width</BUTTON>
    <BUTTON onclick="alert(oDiv.offsetWidth)">offset width</BUTTON>