• javascript判断触发事件event的光标坐标,相对于客户区和屏幕


    相对于客户区的坐标的使用:

    <html>
    <head>
    <script type="text/javascript">
    function show_coords(event)
    {
    x=event.clientX
    y=event.clientY
    alert("X 坐标: " + x + ", Y 坐标: " + y)
    }
    </script>
    </head>

    <body onmousedown="show_coords(event)">

    <p>请在文档中点击。一个消息框会提示出鼠标指针的 x 和 y 坐标。</p>

    </body>
    </html>

     相对于屏幕的坐标的使用:

    <html>
    <head>

    <script type="text/javascript">
    function coordinates(event)
    {
    x=event.screenX
    y=event.screenY
    alert("X=" + x + " Y=" + y)
    }

    </script>
    </head>
    <body onmousedown="coordinates(event)">

    <p>
    在文档中点击某个位置。消息框会提示出指针相对于屏幕的 x 和 y 坐标。
    </p>

    </body>
    </html>

  • 相关阅读:
    分析函数
    Orcal函数
    归档日志
    JSP数据交互
    JSP
    接口
    JAVA修饰符
    QuicKHit
    Java 三章错题
    Java 多态
  • 原文地址:https://www.cnblogs.com/lidabo/p/2616740.html
Copyright © 2020-2023  润新知