event.x,event.clientX,event.offsetX区别

x:设置或者是得到鼠标相对于目标事件的父元素的外边界在x坐标上的位置。 
clientX:相对于客户区域的x坐标位置,不包括滚动条,就是正文区域。 
offsetx:设置或者是得到鼠标相对于目标事件的父元素的内边界在x坐标上的位置。 
screenX:相对于用户屏幕。

演示代码:

<table border=1 cellpadding=15 cellspacing=15 style="position:relative;left:100;top:100">
<tr><td>
<div onclick="show()" style="background:silver;cursor:hand">
Click here to show.
</div>
</td></tr>
</table>
<script>
function show(){
alert("window.event.x:"+window.event.x+" window.event.y:"+window.event.y+" event.clientX:"+event.clientX+" event.clientY:"+event.clientY+" event.offsetX:"+event.offsetX+" event.offsetY:"+event.offsetY+" window.event.screenX:"+window.event.screenX+" window.event.screenY:"+window.event.screenY);
}
</script>

原文地址:https://www.cnblogs.com/hr2014/p/3779320.html