zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    QTableWidget控件总结<一>
    软件工程概论9
    软件工程概论8
    软件工程概论7
    软件工程概论6
    软件工程概论5
    软件工程概论4
    软件工程概论3
    软件工程概论2
    安装gocode教程
  • 原文地址:https://www.cnblogs.com/hr2014/p/3779320.html
Copyright © 2011-2022 走看看