CARVIEW |
Select Language
HTTP/2 200
content-type: text/html
x-guploader-uploadid: AAwnv3IggPTHMVUGKXuwXEMLpLNeCbOcLtpotMbEI-0tP3gp32m5KmLENZ-tUO0VmGOvrAbh
cache-control: public, max-age=3600
expires: Sat, 11 Oct 2025 01:44:11 GMT
last-modified: Fri, 10 Oct 2025 01:11:14 GMT
etag: W/"9453ffd4729a9167865b9a698d2882aa"
x-goog-generation: 1760058674374539
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 154131
x-goog-meta-goog-reserved-file-mtime: 1760056922
x-goog-hash: crc32c=zPg60g==, md5=lFP/1HKakWeGW5ppjSiCqg==
x-goog-storage-class: STANDARD
accept-ranges: none
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
alt-svc: clear
referrer-policy: strict-origin-when-cross-origin
x-content-type-options: nosniff
strict-transport-security: max-age=63072000
content-security-policy: default-src 'self'; script-src 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; script-src-elem 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; style-src 'report-sample' 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; connect-src 'self' developer.allizom.org bcd.developer.allizom.org bcd.developer.mozilla.org updates.developer.allizom.org updates.developer.mozilla.org https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://incoming.telemetry.mozilla.org https://observatory-api.mdn.allizom.net https://observatory-api.mdn.mozilla.net https://api.github.com/search/issues stats.g.doubleclick.net https://api.stripe.com; font-src 'self'; frame-src 'self' interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net mdn.github.io live-samples.mdn.mozilla.net live-samples.mdn.allizom.net *.mdnplay.dev *.mdnyalp.dev *.play.test.mdn.allizom.net https://v2.scrimba.com https://scrimba.com jsfiddle.net www.youtube-nocookie.com codepen.io survey.alchemer.com https://js.stripe.com; img-src 'self' data: *.githubusercontent.com *.googleusercontent.com *.gravatar.com mozillausercontent.com firefoxusercontent.com profile.stage.mozaws.net profile.accounts.firefox.com developer.mozilla.org mdn.dev interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net wikipedia.org upload.wikimedia.org https://mdn.github.io/shared-assets/ https://mdn.dev/ https://*.google-analytics.com https://*.googletagmanager.com www.gstatic.com; manifest-src 'self'; media-src 'self' archive.org videos.cdn.mozilla.net https://mdn.github.io/shared-assets/; child-src 'self'; worker-src 'self';
x-frame-options: DENY
origin-trial: AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=
x-cloud-trace-context: 734fd2b071183af402504e2edf8bcaf2
date: Sat, 11 Oct 2025 00:44:11 GMT
server: Google Frontend
via: 1.1 google
vary: Accept-Encoding
content-encoding: gzip
x-cache: miss
MouseEvent: layerY プロパティ - Web API | MDN
Toggle sidebar
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
MouseEvent: layerY プロパティ
非標準: この機能は標準化されていません。非標準の機能はブラウザーの対応が限られ、将来的に変更または削除される可能性があるため、本番環境での使用は推奨されません。ただし、標準の選択肢が存在しない特定のケースでは、有効な代替手段となる場合があります。
MouseEvent.layerY
は読み取り専用のプロパティで、現在のレイヤーに関連するイベントの垂直座標を返します。
このプロパティは、ページのスクロールを考慮し、文書全体からの相対値を返します。ただし、位置指定された要素内でイベントが発生した場合は、位置指定された要素の左上からの相対値が返されます。
値
整数値で、マウスイベントが発生したときのマウスポインターのピクセル単位の Y 座標です。
例
html
<html lang="en">
<head>
<title>pageX\pageY & layerX\layerY example</title>
<script>
function showCoords(evt) {
const form = document.forms.form_coords;
const parent_id = evt.target.parentNode.id;
form.parentId.value = parent_id;
form.pageXCoords.value = evt.pageX;
form.pageYCoords.value = evt.pageY;
form.layerXCoords.value = evt.layerX;
form.layerYCoords.value = evt.layerY;
}
</script>
<style>
#d1 {
border: solid blue 1px;
padding: 20px;
}
#d2 {
position: absolute;
top: 180px;
left: 80%;
right: auto;
width: 40%;
border: solid blue 1px;
padding: 20px;
}
#d3 {
position: absolute;
top: 240px;
left: 20%;
width: 50%;
border: solid blue 1px;
padding: 10px;
}
</style>
</head>
<body onmousedown="showCoords(event)">
<p>To display the mouse coordinates please click anywhere on the page.</p>
<div id="d1">
<span>
This is an un-positioned div so clicking it will return layerX/layerY
values almost the same as pageX/PageY values.
</span>
</div>
<div id="d2">
<span>
This is a positioned div so clicking it will return layerX/layerY values
that are relative to the top-left corner of this positioned element.
Note the pageX\pageY properties still return the absolute position in
the document, including page scrolling.
</span>
<span>
Make the page scroll more! This is a positioned div so clicking it will
return layerX/layerY values that are relative to the top-left corner of
this positioned element. Note the pageX\pageY properties still return
the absolute position in the document, including page scrolling.
</span>
</div>
<div id="d3">
<form name="form_coords" id="form1">
<label for="parentId">Parent Element id: </label>
<input type="text" name="parentId" size="7" /><br />
<label for="pageXCoords">pageX: </label>
<input type="text" name="pageXCoords" size="7" />
<label for="pageYCoords">pageY: </label>
<input type="text" name="pageYCoords" size="7" /><br />
<label for="layerXCoords">layerX: </label>
<input type="text" name="layerXCoords" size="7" />
<label for="layerYCoords">layerY: </label>
<input type="text" name="layerYCoords" size="7" />
</form>
</div>
</body>
</html>
仕様書
This property is not part of any specification.
ブラウザーの互換性
Loading…