IE中元素位置获取

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function processNode(te) {
var rect = te.getBoundingClientRect();
alert(te.tagName
+ ":" + rect.left + "," + rect.top + ", " + rect.right + "," + rect.bottom);
for (var i = 0; i < te.children.length; i++) {
processNode(te.children[i]);
}
}

function getlayer() {
alert(document.body.all.length);
for (var i = 0; i < document.body.children.length; i++) {
processNode(document.body.children[i]);
}
}
</script>
</head>
<body>

<input value="ko"/>
<input type="button" id="idin" onclick="getlayer();" value="hah" />
<div>
<form>
<img width="90px" height="100px" />
<ul>
<li>liu</li>
<li>jing</li>
<li>wei</li>
</ul>
<input type="submit" value="submit" />
</form>
</div>
</body>
</html>



posted on 2011-10-02 17:41  一颗麦粒  阅读(769)  评论(0编辑  收藏  举报

导航