//获取元素的位置
function getLeft(obj) {
if (obj == null)
null을 반환합니다.
var mendingObj = obj;
var mendingLeft = mendingObj.offsetLeft;
while (mendingObj != null && mendingObj.offsetParent != null && mendingObj.offsetParent.tagName != "BODY") {
mendingLeft = mendingLeft mendingObj.offsetParent.offsetLeft;
mendingObj = mendingObj.offsetParent;
}
반환 수선왼쪽;
};
function getTop(obj) {
if (obj == null)
return null;
var mendingObj = obj;
var mendingTop = mendingObj.offsetTop;
while (mendingObj != null && mendingObj.offsetParent != null && mendingObj.offsetParent.tagName != "BODY") {
mendingTop = mendingTop mendingObj.offsetParent.offsetTop;
mendingObj = mendingObj.offsetParent;
}
mendingTop을 반환합니다.
};
//获取鼠标的位置
function getMousePosition(event) {
var position = {
MouseX: 0,
MouseY: 0
}
if (event.pageX != 정의되지 않음) {
position.MouseX = event.pageX;
position.MouseY = event.pageY;
}
else {
var target = EventUtil.getTarget(event);
position.MouseX = event.offsetX getLeft(대상);
position.MouseY = event.offsetY getTop(target);
}
반환 위치;