<input type="button" onclick="calculate()" value="test">
<script>
function calculate(){
var divs = document.getelementbyid("showtemptext");
divs.innerhtml="wuao ahshahsah <font size=6>111cn.net</font>";
alert(divs.scrollwidth + "__" + divs.scrollheight);
}
</script><html>
<head>
<title>test page</title>
</head>
<body>
<table style="width:100%;">
<tr>
<td>
<div id="div1" style="background:green;">div1</div>
<td>
<td style="width:50%;">
<div id="div2" style="background-color:red;">div2 www.111cn.net</div>
<td>
</table>
<input type="button" onclick="show()" value="show" />
<script>
function show()
{
var o = document.getelementbyid("div1");
var w = o.clientwidth||o.offsetwidth;
alert("div1 s width is "+w);
}
</script>
</body>
</html>
下面是一款利用js获取指定div里面所有图片高度与宽度js怎么获取 这个div内图片的宽度和
<div style="width:100000px;" id="pal">
<img src="/www.111cn.net/images/2009021121575533977.jpg" width="486" height="348" />
<img src="images/2009021121575533977.jpg" />
<img src="images/2009021121575533977.jpg" />
<img src="images/2009021121575533977.jpg" />
<img src="images/2009021121575533977.jpg" />
<img src="images/2009021121575533977.jpg" />
<img src="images/2009021121575533977.jpg" />
<img src="images/2009021121575533977.jpg" />
</div><script>
var obj=document.getelementbyid("pal");
var imgs=obj.getelementsbytagname("img");
var sum=0;
for(var i=0;i<imgs.length;i++)
sum+=imgs[i].width;
alert(sum);
</script>