aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/mouseevent/clienty/index.html
blob: 2c682695d997605e0d52bd2c90cca5ef9e621544 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
title: MouseEvent.clientY
slug: Web/API/MouseEvent/clientY
tags:
  - CSSOM View
  - MouseEvent
translation_of: Web/API/MouseEvent/clientY
---
<p>{{APIRef("DOM Events")}}</p>

<p><strong><code>MouseEvent.clientY</code></strong> 是只读属性, 它提供事件发生时的应用客户端区域的垂直坐标 (与页面坐标不同)。例如,当你点击客户端区域的左上角时,鼠标事件的 <code>clientY</code> 值为 0 ,这一值与页面是否有垂直滚动无关。</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox">var <em>y</em> = <em>instanceOfMouseEvent</em>.clientY
</pre>

<h3 id="Return_value">Return value</h3>

<p>被 CSSOM View Module 重新定义为一个 <code>double</code> 类型的浮点值. 原来这个属性是被定义为一个 <code>long</code> 整数. 可以在 "浏览器兼容性" 那里查看详细内容.</p>

<h3 id="Example" name="Example">Example</h3>

<pre class="brush: js">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;clientX\clientY example&lt;/title&gt;

&lt;script type="text/javascript"&gt;
function showCoords(evt){
  alert(
    "clientX value: " + evt.clientX + "\n"
    + "clientY value: " + evt.clientY + "\n"
  );
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body onmousedown="showCoords(event)"&gt;
&lt;p&gt;To display the mouse coordinates click anywhere on the page.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('CSSOM View','#dom-mouseevent-clienty', 'clientY')}}</td>
   <td>{{Spec2('CSSOM View')}}</td>
   <td>Redefines {{domxref("MouseEvent")}} from <code>long</code> to <code>double</code>.</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM3 Events','#widl-MouseEvent-clientY','MouseEvent.clientY')}}</td>
   <td>{{Spec2('DOM3 Events')}}</td>
   <td>No change from {{SpecName('DOM2 Events')}}.</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent.clientY')}}</td>
   <td>{{Spec2('DOM2 Events')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>



<p>{{Compat("api.MouseEvent.clientY")}}</p>

<h2 id="See_also" name="See_also">查看更多</h2>

<ul>
 <li>{{ domxref("MouseEvent") }}</li>
 <li>{{domxref("MouseEvent.clientX","clientX")}}</li>
 <li>{{domxref("MouseEvent.screenX","screenX")}} / {{domxref("MouseEvent.screenY","screenY")}}</li>
</ul>