欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

scrollWidth,clientWidth與offsetWidth的區(qū)別

 更新時(shí)間:2007年08月22日 20:27:50   作者:  
scrollWidth 
是對(duì)象的實(shí)際內(nèi)容的寬,不包邊線寬度,會(huì)隨對(duì)象中內(nèi)容的多少改變(內(nèi)容多了可能會(huì)改變對(duì)象的實(shí)際寬度)。
clientWidth 
是對(duì)象可見的寬度,不包滾動(dòng)條等邊線,會(huì)隨窗口的顯示大小改變。 
offsetWidth 
是對(duì)象的可見寬度,包滾動(dòng)條等邊線,會(huì)隨窗口的顯示大小改變。 

一個(gè)scrollWidth和clientWidth的例子: 
<html> 
<head> 
<title>77.htm文件</title> 
</head> 
<body> 
<textarea wrap="off" onfocus="alert('scrollWidth:'+this.scrollWidth+'\n clientWidth:'+this.clientWidth);"></textarea> 
</body> 
</html> 
在文本框內(nèi)輸入內(nèi)容,當(dāng)橫向滾動(dòng)條沒(méi)出來(lái)前scrollWidth和clientWidth的值是一樣的。當(dāng)一行內(nèi)容超出文本框的寬度,就有橫向滾動(dòng)條出來(lái)了,scrollWidth的值就變了。 
scrollWidth是對(duì)象實(shí)際內(nèi)容的寬度。 
clientWidth是對(duì)象看到的寬度(不含邊線),這個(gè)例子里不會(huì)改變。 

一個(gè)clientWidth和offsetWidth的例子: 
<html> 
<head> 
<title>77.htm文件</title> 
</head> 
<body> 
<textarea wrap="off" onfocus="alert('offsetWidth:'+this.offsetWidth+'\n clientWidth:'+this.clientWidth);"></textarea> 
</body> 
</html> 
offsetWidth的值總是比clientWidth的值大。 
clientWidth是對(duì)象看到的寬度(不含邊線) 
offsetWidth是對(duì)象看到的寬度(含邊線,如滾動(dòng)條的占用的寬) 

相關(guān)文章

最新評(píng)論