将CSS这样定义,将宽度和高度定义在内层容器
<HTML>
<BODY>
<DIV>
<DIV id="adspace" style="background-color:gray;width:100px;height:100px;overflow:hidden;">SASSASAAAAAAAAAAAAAAAA Scvaa</DIV>
</DIV>
<script lanaguge="javascript">
var e = document.getElementById('adspace');
alert("offsetWidth:" + e.offsetWidth);
alert("offsetHeight:" + e.offsetHeight);
</script>
</BODY>
</HTML>
<HTML>
<BODY>
<DIV>
<DIV id="adspace" style="background-color:gray;width:100px;height:100px;overflow:hidden;">SASSASAAAAAAAAAAAAAAAA Scvaa</DIV>
</DIV>
<script lanaguge="javascript">
var e = document.getElementById('adspace');
alert("offsetWidth:" + e.offsetWidth);
alert("offsetHeight:" + e.offsetHeight);
</script>
</BODY>
</HTML>
高度是变的,宽度不变的原因是 你这个层没有 <DIV id="adspace" style="background-color:gray;float:left"> 这样宽度就变化了