<SCRIPT>
function getCoords(oObject) {
    oBndRct=oObject.getBoundingClientRect();
    alert(oBndRct.left);
}
</SCRIPT>
</HEAD>
<BODY>
sdddddd<input type="text" ID=oPara onclick="getCoords(this)">

解决方案 »

  1.   

    <script language="JavaScript">
    <!--
    //** power by fason
    function getPosition(el) 
    {
    var o = el.offsetParent, x = el.offsetLeft, y = el.offsetTop;
    while (o.tagName != 'BODY') {
    x += o.offsetLeft;
    y += o.offsetTop;
    o = o.offsetParent;
    }
    return {
    "left": x,
    "top": y
    };
    };
    //-->
    </script>
    <center><input onclick="alert(getPosition(this).left)"></center>
      

  2.   

    function GetDefineX(ObjectID)
    {
    var iPositionX=ObjectID.offsetLeft;
    while(ObjectID=ObjectID.offsetParent)
    {
    iPositionX+=ObjectID.offsetLeft;
    }
    return iPositionX;
    }