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

  x:设置或者是得到鼠标相对于目标事件的父元素的外边界在x坐标上的位置。

  clientX:相对于客户区域的x坐标位置,不包括滚动条,就是正文区域。

  offsetx:设置或者是得到鼠标相对于目标事件的父元素的内边界在x坐标上的位置。

  screenX:相对于用户屏幕。

  测试代码一:

  [code]

  <html>

  <head>

  </head>

  <script>

  function reload(){

  window.location.reload("http://www.glzy8.com");

  }

  </script>

  <body>

  <table>

  <TR><TD><input type="button" name="button1" value="button1" onclick="reload();"></TD><TD></TD></TR>

  <TR><TD><input type="button" name="button2" value="button2" onclick="reload();"></TD><TD></TD></TR>

  </table>

  <input type="button" name="update" value="刷新" onclick="reload();">

  <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>

  <input type="button" name="button" value="button" onclick="reload();">

  </body>

  </html>

  <script>

  function window.onbeforeunload()

  {

  alert('event.clientX='+event.clientX);//如果是鼠标点击“刷新”按钮,则跟鼠标点击时的位置有关

  alert('event.offsetX='+event.offsetX);

  alert('document.body.clientWidth='+document.body.clientWidth);

  alert('event.clientY='+event.clientY);

  alert('event.offsetY='+event.offsetY);

  alert('event.altKey='+event.altKey);

  if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)

  {

  window.event.returnValue="确定要退出本页吗?";

  }else

  {

  alert("你在刷新");

  }

  }

  </script>

  [/html]

  演示代码二:

  

   [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]