`
gudao8192
  • 浏览: 95329 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

getBoundingClientRect()

阅读更多

html的对象可以通过getBoundingClientRect()取得其真实位置:

<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>无标题文档</title>
</head>

<body>
<tablewidth="200"border="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><tablewidth="362"border="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<tdheight="135">&nbsp;</td>
<td>&nbsp;</td>
<td><tablewidth="200"border="1"cellpadding="0"cellspacing="0"bordercolor="#0000FF"id="aa"style="border-collapse:collapse;">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table></td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
<scriptlanguage="javascript">...
//alert(aa.getBoundingClientRect()["right"]);
alert(aa.getBoundingClientRect().right);
for(variinaa.getBoundingClientRect())...{
document.writeln(i
+"="+aa.getBoundingClientRect()[i]);
}

</script>
</body>
</html>


转自:http://blog.csdn.net/sungcong/archive/2005/12/09/547848.aspx

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics