MouseEvent.clientY

您正在阅读此内容的英文版本,因为该语系尚未翻译。 帮助我们翻译此文章吧!

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

语法

var y = instanceOfMouseEvent.clientY

Return value

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

Example

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

<script type="text/javascript">
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
CSS Object Model (CSSOM) View Module
clientY
Working Draft Redefines MouseEvent from long to double.
Document Object Model (DOM) Level 3 Events Specification
MouseEvent.clientY
Obsolete No change from Document Object Model (DOM) Level 2 Events Specification.
Document Object Model (DOM) Level 2 Events Specification
MouseEvent.clientY
Obsolete Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
clientYChrome Full support YesEdge Full support 12Firefox Full support YesIE Full support 6Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
Value type changed from long to doubleChrome Full support 56Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android Full support 56Chrome Android Full support 56Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

查看更多