获取鼠标事件的鼠标x|y坐标

 

关于Event相关的可以参考http://zhangyaochun.iteye.com/blog/1439502

兼容性参考http://zhangyaochun.iteye.com/blog/1439543

 


/*
*pointer ---the mouse position x/y*
*@function*
*@param {Event} event*
*/
ZYC.event.pointer = function(event){
    return {
	  //getX---ZYC.event.pointer(event).x
	  x: event.pageX || ((event.clientX || 0)
	                    + (document.documentElement.scrollLeft || document.body.scrollLeft));   
	  
	  //getY---ZYC.event.pointer(event).y
	  y: event.pageY || ((event.clientY || 0)
	                    + (document.documentElement.scrollTop || document.body.scrollTop));   
	};
};