javascript:对象的四个宽高属性值
1 <html> 2 <head> 3 <title>1</title> 4 <style type='text/css'> 5 #box{ 6 width:300px; 7 height:200px; 8 border:dashed 1px green; 9 overflow:auto; 10 } 11 </style> 12 </head> 13 <body> 14 <div id='box' onclick="fun();"> 15 <script language='javascript'> 16 for(var i=0;i<150;i++){ 17 document.writeln('<br/>'); 18 } 19 </script> 20 </div> 21 <script language='javascript'> 22 function fun(){ 23 var obj=document.getElementById('box'); 24 alert(obj.clientWidth+'/'+obj.clientHeight+'\n'+ 25 obj.scrollWidth+'/'+obj.scrollHeight+'\n'+ 26 obj.offsetWidth+'/'+obj.offsetHeight+'\n'+ 27 obj.scrollLeft+'/'+obj.scrollTop 28 );//与document.body.scrollLeft比较 29 window.scrollTo(0,200);//用来制作锚点 30 } 31 </script> 32 <script language='javascript'> 33 for(var i=0;i<150;i++){ 34 document.writeln('<br/>'); 35 } 36 </script> 37 </body> 38 </html>