clientYイベントプロパティ
イベントオブジェクト
定義と使い方
clientY イベントプロパティは、イベントがトリガーされたときにマウスポインターのブラウザーページ(クライアント領域)に対する垂直座標を返します。クライアント領域は現在のウィンドウを指します。
構文
event.clientY
例
例
次の例では、イベント発生時のマウスポインターの座標を表示します:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function show_coords(event){
var x=event.clientX;
var y=event.clientY;
alert("X coords: " + x + ", Y coords: " + y);
}
</script>
</head>
<body>
<p onmousedown="show_coords(event)">ドキュメント内をクリックしてください。メッセージボックスにマウスポインターのx座標とy座標が表示されます。</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function show_coords(event){
var x=event.clientX;
var y=event.clientY;
alert("X coords: " + x + ", Y coords: " + y);
}
</script>
</head>
<body>
<p onmousedown="show_coords(event)">ドキュメント内をクリックしてください。メッセージボックスにマウスポインターのx座標とy座標が表示されます。</p>
</body>
</html>
試してみる »
イベントオブジェクト その他の拡張