clientWidth,offsetWidth,scrollWidth

理解clientWidth等属性
本文详细解释了clientWidth、offsetWidth和scrollWidth这三个属性的区别与用法,并通过一个实例帮助读者更好地理解这些概念。

转: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.
(以像素为单位显示一个非负长整型的宽度值)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值