61,112
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
function Obj(s){
return document.getElementById(s)?document.getElementById(s):s;
}
function GetClientWidth(o){
return Obj(o).clientWidth;
}
function GetClientHeight(o){
return Obj(o).clientHeight;
}
</script>
</head>
<body>
<div id='abc' style="overflow-y:scroll;margin: 10px; padding: 10px; width: 200px; height: 200px; border: solid 10px blue;">
<p><a href="javascript:alert(GetClientHeight('abc')*1-GetClientWidth('abc')*1);">取滚动条宽度</a></p>
<br>一个方形DIV容器;CLIENT尺寸应该相同;但有了滚动条后发生变化;差值就是滚动条的宽度
</body> </html>