用Javascript获取鼠标坐标的代码

用Javascript获取鼠标坐标的代码:

方法1:相对于浏览器窗口坐标
mouX = window.event.clientX;
mouY = window.event.clientY;

方法2:相对于整个页面文档的坐标
mouX = window.event.client.x;
mouY = window.event.client.y;

这里需要注意的是FF并没有event,但我们可以通过把event传递进去就可以了.

比如:

function aa(event){
   alert(event.pageY);
  }

Leave a Reply

Spam Protection by WP-SpamFree