Code
<HTML>
<SCRIPT language="javascript">
function getPos(obj)
{
var pos = new Array();
var t=obj.offsetTop;
var l=obj.offsetLeft;
while(obj=obj.offsetParent)
{
t+=obj.offsetTop;
l+=obj.offsetLeft;
}
pos[0] = t;
pos[1] = l;
return pos;
}
function test(obj)
{
var arr = new Array();
arr = getPos(obj);
alert(arr[0] + ":" + arr[1]);
alert("对象的宽度" + obj.offsetWidth );
alert("对象的高度" + obj.offsetHeight );
}
</SCRIPT>
<BODY>
<IMG src="" id="img" width="100" height="100" onClick="test(this)">
</BODY>
</HTML>
posted on
2009-08-05 23:13
侯Vincent
阅读(
310)
评论()
编辑
收藏
举报