function CPos(x, y) { this.x = x; this.y = y;} // 获取控件的位置 function GetObjPos(ATarget) { var target = ATarget; var pos = new CPos(target.offsetLeft, target.offsetTop); var target = target.offsetParent; while (target) { pos.x += target.offsetLeft; pos.y += target.offsetTop; target = target.offsetParent } return pos;} 转载于:https://www.cnblogs.com/itcom/archive/2008/09/03/1283316.html