DHTML Object Properties DHTML Objects
Retrieves the width of the object, in pixels, without taking into account any margin, border, scroll bar, or padding that might have been applied to the object.
HTML |
N/A |
Script |
[ iWidth = ] object.clientWidth |
iWidth |
Integer specifying the width of the object, in pixels. |
The property is read-only with no default value.
The following example demonstrates the difference between the clientWidth style attribute and the offsetWidth property in measuring the document width. Note The DIV's width is set to 200, and this is the value retrieved by the offsetWidth, not the clientWidth.
<div id=oDiv
STYLE="overflow:scroll; width:200; height:100">
. . . </div>
<button onclick="alert ( oDiv.clientWidth )">
client width</button>
<button onclick="alert ( oDiv.offsetWidth )">
offset width</button>
Show me
Measuring Element Dimension and Location, The Browser Screen