From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/mouseevent/screenx/index.html | 130 +++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 files/ja/web/api/mouseevent/screenx/index.html (limited to 'files/ja/web/api/mouseevent/screenx') diff --git a/files/ja/web/api/mouseevent/screenx/index.html b/files/ja/web/api/mouseevent/screenx/index.html new file mode 100644 index 0000000000..be8c826012 --- /dev/null +++ b/files/ja/web/api/mouseevent/screenx/index.html @@ -0,0 +1,130 @@ +--- +title: MouseEvent.screenX +slug: Web/API/MouseEvent/screenX +translation_of: Web/API/MouseEvent/screenX +--- +

{{APIRef("DOM Events")}}

+ +

MouseEvent.screenX は、イベントの発生した位置の、スクリーン内での X 座標を参照できる読み取り専用の属性です。

+ +

記法

+ +
var pixelNumber = instanceOfMouseEvent.screenX
+
+ +

返り値

+ + + +

使用例

+ +
<html>
+<head>
+<title>screenX\screenY example</title>
+
+<script type="text/javascript">
+
+function showCoords(evt){
+  alert(
+    "screenX value: " + evt.screenX + "\n"
+    + "screenY value: " + evt.screenY + "\n"
+  );
+}
+
+</script>
+</head>
+
+<body onmousedown="showCoords(event)">
+<p>To display the mouse coordinates click anywhere on the page.</p>
+</body>
+</html>
+
+ +

window や document のような領域の広い要素に対してイベントを処理する場合、以下のように座標を元に適切な処理を呼び出すことができます。

+ +
function checkClickMap(e) {
+  if (e.screenX < 50) doRedButton();
+  if (50 <= e.screenX && e.screenX < 100) doYellowButton();
+  if (e.screenX >= 100) doRedButton();
+}
+
+ +

仕様

+ + + + + + + + + + + + + + + + + + + +
仕様状態コメント
{{SpecName('DOM3 Events','#widl-MouseEvent-screenX','MouseEvent.screenX')}}{{Spec2('DOM3 Events')}} {{SpecName('DOM2 Events')}} からの変更なし
{{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent.sceenX')}}{{Spec2('DOM2 Events')}}最初の定義
+ +

ブラウザ互換性

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
機能Firefox (Gecko)ChromeInternet ExplorerOperaSafari
基本サポート{{CompatVersionUnknown()}}{{CompatVersionUnknown()}}6{{CompatVersionUnknown()}}{{CompatVersionUnknown()}}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
機能Firefox Mobile (Gecko)AndroidIE MobileOpera MobileSafari Mobile
基本サポート{{CompatVersionUnknown()}}{{CompatVersionUnknown()}}{{CompatVersionUnknown()}}{{CompatVersionUnknown()}}{{CompatVersionUnknown()}}
+
+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf