javascript|js|动态我现在有一个层,层中有一个div,当内容比较多的时候就出现滚动条,我现在想,当滚动条出现的时候,div中表格的宽度等于div的宽度减去滚动条的宽度,如何才能去动态获得滚动条的宽度,或者判断滚动条的状态既是否出现.
------------------------------------------------------------------------------------
是不是想这样?
<div id="demo" id="d2" {
top=demo.offsetTop;
left=demo.offsetLeft;
width=demo.scrollWidth;
height=demo.offsetHeight;
}
</script>
-------------------------------------------------------------------------------------- 如果我没有理解错的话,直接减不就可以了吗?
<div id="demo" id="d2" "+demo.offsetWidth);
alert("div滚动宽度: "+demo.scrollWidth);
alert("scrollbar宽度: "+(parseInt(demo.offsetWidth)-parseInt(demo.scrollWidth)));
demo.inner = "never-online<br/>never-online<br/>never-online<br/>never-online<br/>never-online<br/>never-online<br/>never-online<br/>never-online<br/>"
alert("div宽度: "+demo.offsetWidth);
alert("div滚动宽度: "+demo.scrollWidth);
alert("scrollbar宽度: "+(parseInt(demo.offsetWidth)-parseInt(demo.scrollWidth)));
with(d2.style) {
top=demo.offsetTop;
left=demo.offsetLeft;
width=demo.scrollWidth;
height=demo.offsetHeight;
}
</script>
--------------------------------------------------------------------------------------
js动态获得滚动条宽度 JavaScript,js
80酷酷网 80kuku.com