aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/mouseevent/clientx/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/mouseevent/clientx/index.html')
-rw-r--r--files/zh-cn/web/api/mouseevent/clientx/index.html85
1 files changed, 85 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/mouseevent/clientx/index.html b/files/zh-cn/web/api/mouseevent/clientx/index.html
new file mode 100644
index 0000000000..009b338b12
--- /dev/null
+++ b/files/zh-cn/web/api/mouseevent/clientx/index.html
@@ -0,0 +1,85 @@
+---
+title: MouseEvent.clientX
+slug: Web/API/MouseEvent/clientX
+tags:
+ - API
+ - DOM
+ - DOM Events
+translation_of: Web/API/MouseEvent/clientX
+---
+<p>{{APIRef("DOM Events")}}</p>
+
+<p><strong><code>MouseEvent.clientX</code></strong> 是只读属性, 它提供事件发生时的应用客户端区域的水平坐标 (与页面坐标不同)。例如,不论页面是否有水平滚动,当你点击客户端区域的左上角时,鼠标事件的 <code>clientX</code> 值都将为 0 。最初这个属性被定义为长整型(long integer),如今 <strong>CSSOM </strong>视图模块将其重新定义为双精度浮点数(double float)。你可以查阅浏览器兼容性部分的文档来进一步了解有关信息。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><code>
+var <em>x</em> = <em>instanceOfMouseEvent</em>.clientX
+</code></pre>
+
+<h3 id="返回值"><code>返回值</code></h3>
+
+<p>被 CSSOM View Module 重新定义为一个 <code>double</code> 类型的浮点值. 原来这个属性是被定义为一个 <code>long</code> 整数. 可以在 "浏览器兼容性" 那里查看详细内容.</p>
+
+<h2 id="Example" name="Example">示例</h2>
+
+<pre class="brush: html">&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+ &lt;head&gt;
+ &lt;title&gt;clientX/clientY example&lt;/title&gt;
+
+ &lt;script&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-clientx', 'clientX')}}</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-clientX','MouseEvent.clientX')}}</td>
+ <td>{{Spec2('DOM3 Events')}}</td>
+ <td>No change from {{SpecName('DOM2 Events')}}.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent.clientX')}}</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.clientX")}}</p>
+
+<h2 id="See_also" name="See_also">相关</h2>
+
+<ul>
+ <li><code><code>{{ domxref("MouseEvent") }}</code></code></li>
+ <li><code><code>{{domxref("event.clientY","clientY")}}</code></code></li>
+ <li><code><code>{{domxref("event.screenX","screenX")}} / {{domxref("event.screenY","screenY")}}</code></code></li>
+</ul>