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>



原文地址:https://www.cnblogs.com/kwliu/p/2198070.html