diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/mouseevent/screenx | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/ja/web/api/mouseevent/screenx')
-rw-r--r-- | files/ja/web/api/mouseevent/screenx/index.html | 130 |
1 files changed, 130 insertions, 0 deletions
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 +--- +<p>{{APIRef("DOM Events")}}</p> + +<p><strong><code>MouseEvent.screenX</code></strong> は、イベントの発生した位置の、スクリーン内での X 座標を参照できる読み取り専用の属性です。</p> + +<h2 id="記法">記法</h2> + +<pre class="syntaxbox">var <em>pixelNumber</em> = <em>instanceOfMouseEvent</em>.screenX +</pre> + +<h3 id="返り値">返り値</h3> + +<ul> + <li><em><code>pixelNumber</code></em> はスクリーンの左上の点からのピクセル数です。</li> +</ul> + +<h3 id="Example" name="Example">使用例</h3> + +<pre class="brush: html"><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> +</pre> + +<p>window や document のような領域の広い要素に対してイベントを処理する場合、以下のように座標を元に適切な処理を呼び出すことができます。</p> + +<pre class="brush: js">function checkClickMap(e) { + if (e.screenX < 50) doRedButton(); + if (50 <= e.screenX<span style="font-size: 1rem;"> && </span>e.screenX<span style="font-size: 1rem;"> < 100)</span><span style="font-size: 1rem;"> doYellowButton(); +</span> if (e.screenX >= 100) doRedButton(); +} +</pre> + +<h2 id="仕様">仕様</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">仕様</th> + <th scope="col">状態</th> + <th scope="col">コメント</th> + </tr> + <tr> + <td>{{SpecName('DOM3 Events','#widl-MouseEvent-screenX','MouseEvent.screenX')}}</td> + <td>{{Spec2('DOM3 Events')}}</td> + <td> {{SpecName('DOM2 Events')}} からの変更なし</td> + </tr> + <tr> + <td>{{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent.sceenX')}}</td> + <td>{{Spec2('DOM2 Events')}}</td> + <td>最初の定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザ互換性</h2> + +<p>{{ CompatibilityTable() }}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>機能</th> + <th>Firefox (Gecko)</th> + <th>Chrome</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>基本サポート</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>6</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>機能</th> + <th>Firefox Mobile (Gecko)</th> + <th>Android</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>基本サポート</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + <td>{{CompatVersionUnknown()}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{ domxref("MouseEvent") }}</li> +</ul> |