`
莫生气
  • 浏览: 861497 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

转:clientWidth、offsetWidth和scrollWidth

阅读更多

< meta http-equiv="Content-Type" Content="text/html; charset=utf-8">
< textarea wrap="off" onmouseover=
"alert(' clientWidth:'+this.clientWidth+
'\n offsetWidth:'+this.offsetWidth+'\n scrollWidth:'+this.scrollWidth);">
11111111111111111111111111111
< /textarea>
clientWidth是对象看到的宽度(不含边线)
offsetWidth是对象看到的宽度(含边线,如滚动条的占用的宽,值会随着内容的输入而不断改变)
scrollWidth是对象实际内容的宽度。

手册里面说的并不是很清楚,可以根据上面的例子加深理解。

clientWidth语法:
Scripting [ iWidth = ] object.clientWidth
clientWidth的值:
iWidth Integer that receives the width of the object, in pixels.
(以像素为单位显示对象的宽度)

offsetWidth语法:
Scripting [ iWidth = ] object.offsetWidth
offsetWidth的值:
iWidth Integer that receives the width, in pixels.
(以像素为单位显示宽度)

scrollWidth语法:
Scripting [ iWidth = ] object.scrollWidth
scrollWidth的值:
iWidth Pointer to a nonnegative long integer that specifies the width, in pixels.
(以像素为单位显示一个非负长整型的宽度值)

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics