Prototype-event-pointerx

提供:Dev Guides
移動先:案内検索

プロトタイプ-イベントpointerX()メソッド

このメソッドは、マウスイベントの絶対水平位置を返します。

構文

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>

出力