<script type="text/javascript">
//<![CDATA[
onload=function(){
var o=document.getElementById('MsgBox7');
defaultStatus=o.offsetLeft+' '+o.offsetTop+' '+
o.offsetWidth+' '+o.offsetTop+' '+o.offsetParent.nodeName
}
//]]>
</script>
<a id="MsgBox7" href="">点击查看</a>
//<![CDATA[
onload=function(){
var o=document.getElementById('MsgBox7');
defaultStatus=o.offsetLeft+' '+o.offsetTop+' '+
o.offsetWidth+' '+o.offsetTop+' '+o.offsetParent.nodeName
}
//]]>
</script>
<a id="MsgBox7" href="">点击查看</a>
---------------------------------
getBoundingClientRect Method--------------------------------------------------------------------------------Retrieves an object that specifies the bounds of a collection of TextRectangle objects. SyntaxoRect = object.getBoundingClientRect()
Return ValueReturns a TextRectangle object. Each rectangle has four integer properties (top, left, right, and bottom) that represent a coordinate of the rectangle, in pixels.ResThis method retrieves an object that exposes the left, top, right, and bottom coordinates of the union of rectangles relative to the client's upper-left corner. In Microsoft Internet Explorer 5, the window's upper-left is at 2,2 (pixels) with respect to the true client.
但改一下就更直观了:<a id="MsgBox7" href="javascript:dp();">点击查看本链接元素的位置</a>
<script type="text/javascript">
function dp(){
var o=document.getElementById('MsgBox7');
alert('Left:' + o.offsetLeft+' Top:'+o.offsetTop+' Width:'+ o.offsetWidth+' Height:'+o.offsetHeight+' NodeName:'+o.offsetParent.nodeName);
}
</script>