滑鼠事件中 screenY 的角色是什麼?


事件觸發後,screenY 滑鼠事件返回滑鼠指標的垂直座標。

示例

可以嘗試執行以下程式碼,學習如何在 JavaScript 中實現 screenY 滑鼠事件。

<!DOCTYPE html>
<html>
   <body>
      <p onclick = "coordsFunc(event)">Click here to get the x (horizontal) and y (vertical) coordinates of the mouse pointer.</p>
     
      <script>
         function coordsFunc(event) {
            var x_coord = event.screenX;
            var y_coord = event.screenY;
            var xycoords = "X coords= " + x_coord + ", Y coords= " + y_coord;
            document.write(xycoords);
         }
      </script>
   </body>
</html>

更新時間: 2020 年 5 月 23 日

70 次訪問

開啟你的職業生涯

完成本課程以獲得認證

開始
廣告