非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

UIEvent.pageY read-only property returns the vertical coordinate of the event relative to the whole document.

句法

var pageY = event.pageY;
					

pageY is an integer value in pixels for the y-coordinate of the mouse pointer, relative to the whole document, when the mouse event fired. This property takes into account any vertical scrolling of the page.

范例

<html>
<head>
<title>pageX\pageY & layerX\layerY example</title>
<script type="text/javascript">
function showCoords(evt){
  var form = document.forms.form_coords;
  var parent_id = evt.target.parentNode.id;
  form.parentId.value = parent_id;
  form.pageXCoords.value = evt.pageX;
  form.pageYCoords.value = evt.pageY;
  form.layerXCoords.value = evt.layerX;
  form.layerYCoords.value = evt.layerY;
}
</script>
<style type="text/css">
 #d1 {
  border: solid blue 1px;
  padding: 20px;
 }
 #d2 {
  position: absolute;
  top: 180px;
  left: 80%;
  right:auto;
  width: 40%;
  border: solid blue 1px;
  padding: 20px;
 }
 #d3 {
  position: absolute;
  top: 240px;
  left: 20%;
  width: 50%;
  border: solid blue 1px;
  padding: 10px;
 }
</style>
</head>
<body onmousedown="showCoords(event)">
<p>To display the mouse coordinates please click anywhere on the page.</p>
<div id="d1">
<span>This is an un-positioned div so clicking it will return
layerX/layerY values almost the same as pageX/PageY values.</span>
</div>
<div id="d2">
<span>This is a positioned div so clicking it will return layerX/layerY
values that are relative to the top-left corner of this positioned
element. Note the pageX\pageY properties still return the
absolute position in the document, including page scrolling.</span>
<span>Make the page scroll more! This is a positioned div so clicking it
will return layerX/layerY values that are relative to the top-left
corner of this positioned element. Note the pageX\pageY properties still
return the absolute position in the document, including page
scrolling.</span>
</div>
<div id="d3">
<form name="form_coords">
 Parent Element id: <input type="text" name="parentId" size="7" /><br />
 pageX:<input type="text" name="pageXCoords" size="7" />
 pageY:<input type="text" name="pageYCoords" size="7" /><br />
 layerX:<input type="text" name="layerXCoords" size="7" />
 layerY:<input type="text" name="layerYCoords" size="7" />
</form>
</div>
</body>
</html>
					

规范

This property is not part of any specification.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
pageY 弃用 非标 Chrome ? — 44
不支持 ? — 44
Replaced by MouseEvent.pageY in version 45.
Edge 12 Firefox ? IE 9 Opera ? Safari ? WebView Android ? — 44
不支持 ? — 44
Replaced by MouseEvent.pageY in version 45.
Chrome Android ? — 44
不支持 ? — 44
Replaced by MouseEvent.pageY in version 45.
Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ? — 4.0
不支持 ? — 4.0
Replaced by MouseEvent.pageY in Samsung Internet 5.0.

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

另请参阅

元数据

  • 最后修改:
  1. UIEvent
  2. 构造函数
    1. UIEvent()
  3. 特性
    1. cancelBubble
    2. detail
    3. isChar
    4. layerX
    5. layerY
    6. pageX
    7. pageY
    8. sourceCapabilities
    9. view
  4. 方法
    1. initUIEvent
  5. 事件
    1. initUIEvent
  6. 继承:
    1. 事件
  7. DOM 事件相关页面
    1. CompositionEvent
    2. 事件
    3. EventListener
    4. EventTarget
    5. FocusEvent
    6. InputEvent
    7. KeyboardEvent
    8. MouseEvent
    9. MouseScrollEvent
    10. MouseWheelEvent
    11. MutationEvent
    12. ProgressEvent
    13. WheelEvent

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1