Microsoft Visual Studio 2010做的C#获取鼠标相对窗口位置实例,主要代码: Point formPoint = this.PointToClient(Control.MousePosition);//鼠标相对于窗体左上角的坐标 int iX = formPoint.X; int iY = formPoint.Y; string sPosition = "(" + iX.ToString() + "," + iY.ToString() + ")& quot;; labe
本文实例讲述了JS获取鼠标相对位置的方法。分享给大家供大家参考,具体如下:
位置
[removed]
function m(){
document.getElementById("area")[removed]=event.clientX +" , "+event.clientY;
}
function c(){
var objTop =
代码如下: JS获取DIV相对坐标 [removed]<!– function getX(obj){ var parObj=obj; var left=obj.offsetLeft; while(parObj=parObj.offsetParent){ left+=parObj.offsetLeft; } return left; } function getY(obj){ var parObj=obj; var top=obj.offsetTop; while(parObj = pa