MouseEvent: screenY プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

screenYMouseEvent インターフェイスの読み取り専用プロパティで、グローバル(スクリーン)座標における、マウスポインターの垂直方向の座標(オフセット)を示します。

double の浮動小数点値です。

これを定義する早期の版の仕様書では、ピクセル数を表す整数として定義していました。

この例では、 mousemove イベントが発行されるたびにマウスの座標を表示します。

HTML

html
<p>マウスを動かして、位置を確認してください。</p>
<p id="screen-log"></p>

JavaScript

js
let screenLog = document.querySelector("#screen-log");
document.addEventListener("mousemove", logKey);

function logKey(e) {
  screenLog.innerText = `
    Screen X/Y: ${e.screenX}, ${e.screenY}
    Client X/Y: ${e.clientX}, ${e.clientY}`;
}

結果

仕様書

Specification
UI Events
# dom-mouseevent-screeny

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
screenY

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報