日期:2014-05-17 浏览次数:20575 次
<html>
<head>
<title>Chapter 3 Project</title>
<style type="text/css">
body
{
margin:0px;
padding:0px;
}
</style>
<script type="text/javascript">
window.onload = function() {
var obj = document.getElementById("loca");
findPos(obj);
}
function findPos(obj) {
var curleft = 0;
var curtop = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
obj = obj.offsetParent;
}
}
return [curleft, curtop];
}
</script>
</head>
<body>
<div style="position:relative">
<div id="loca" style="position:absolute;left:100px;top:200px;">
</div>
</div>
</body>
</html>