Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

MouseEvent.clientX

这篇翻译不完整。请帮忙从英语翻译这篇文章

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

语法

var x = instanceOfMouseEvent.clientX

返回值

一个数字

示例

<!DOCTYPE html> 
<html>
<head>
<title>clientX\clientY example</title>

<script>
function showCoords(evt){
  alert(
    "clientX value: " + evt.clientX + "\n" +
    "clientY value: " + evt.clientY + "\n"
  );
}
</script>
</head>

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

规范

Specification Status Comment
Document Object Model (DOM) Level 3 Events Specification
MouseEvent.clientX
Working Draft No change from Document Object Model (DOM) Level 2 Events Specification.
Document Object Model (DOM) Level 2 Events Specification
MouseEvent.clientX
Recommendation Initial definition.

浏览器兼容性

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Firefox Mobile (Gecko) Android IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? ? ?

相关

文档标签和贡献者

 此页面的贡献者: Tienyz
 最后编辑者: Tienyz,