复制代码 代码如下:
var xPos;
var yPos;
document.onmousemove = mouseMove;
function mouseMove(ev) {
ev = ev window.event;
var mousePos = mouseCoords(ev);
xPos = mousePos.x;
yPos = mousePos.y;
}
function mouseCoords(ev) {
if (ev.pageX ev.pageY) {
return { x: ev.pageX, y: ev.pageY };
}
return {
x:ev.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,
y:ev.clientY + document.body.scrollTop + document.documentElement.scrollTop
};
}
var xPos;
var yPos;
document.onmousemove = mouseMove;
function mouseMove(ev) {
ev = ev window.event;
var mousePos = mouseCoords(ev);
xPos = mousePos.x;
yPos = mousePos.y;
}
function mouseCoords(ev) {
if (ev.pageX ev.pageY) {
return { x: ev.pageX, y: ev.pageY };
}
return {
x:ev.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,
y:ev.clientY + document.body.scrollTop + document.documentElement.scrollTop
};
}
标签:
javascript,鼠标,位置
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“javascript获取鼠标位置部分的实例代码(兼容IE,FF)”评论...