JS当前鼠标点击位置

发布:2011-11-29 17:08   点击1058次   评论:0


<img src="images/a.gif" onclick="GetPosition(event)" />
<script>
function GetPostion(e) {
var x = getX(e);
var y = getY(e);
}
function getX(e) {
e = e || window.event;
return e.pageX || e.clientX + document.body.scroolLeft;
}
function getY(e) {
e = e|| window.event;
return e.pageY || e.clientY + document.boyd.scrollTop;
}
</script>




function mouseMove(ev) {
ev2 = ev || window.event;
mousePos = mouseCoords(ev2);
}
function mouseCoords(ev) {
if (ev.pageX || ev.pageY) {
return { x: ev.pageX, y: ev.pageY };
}
try{ //IE6下,在开窗中再打开设置窗,显示错误,但不影响功能。
 return { 
x: ev.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft),
y: ev.clientY + (document.documentElement.scrollTop || document.body.scrollTop)
 };
}catch(e){}
}
var aListSetMoving = new aListSetMove();//创建移动层的实例
var mousePos; document.Onmousemove = mouseMove;

关于 GitHub 导航 部门 反馈

提示:`/home.php`入口数据仅为演示功能,不构成任何交易凭证,也不承担相关风险和责任!

Copyright © 2011-2018 xxxxx.com All rights reserved.

Run:2.677/31.543(ms); 7(sql)/2.878(MB); comm:news/detail; Upd:2025-01-11 07:07:44