Prototype – 事件 pointerX() 方法

返回到:Prototype – 事件处理

此方法返回鼠标事件的绝对水平位置。

句法

Event.pointerX(event);

返回值

返回鼠标事件的绝对水平位置。

例子

通过点击不同的地方来尝试这个例子。

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>
      
      <script>
         // Register event 'click' and associated call back.
         Event.observe(document, 'click', respondToClick);
  
         // Callback function to handle the event.
         function respondToClick(event) {
            var x_axis = Event.pointerX(event);
            alert("Horizontal position : "  + x_axis);
         }
      </script>
   </head>

   <body>
      <p id = "note">Click anywhere to see the result.</p>
      <p id = "para1">This is paragraph 1</p>
      <p id = "para2">This is paragraph 2</p>
      <div id = "division">This is divsion.</div>
   </body>
</html>

返回到:Prototype – 事件处理

作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8545.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2023年1月31日
下一篇 2023年1月31日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注