目录

MouseEvent pageY Property

Example

Get the coordinates of the mouse pointer when the mouse button is clicked:

let x = event.pageX;  // Horizontal
let y = event.pageY;  // Vertical
Try it Yourself »

More examples below.


Description

The pageY property returns the document relative coordinate the mouse pointer when a mouse event occurs.

The pageY property is read-only.

The document is the web page.


Coordinate Properties

Property Relative to
The screenX Property The Screen area
The screenY Property The Screen area
The clientX Property The Window area
The clientY Property The Window area
The pageX Property The Page (Document)
The pageY Property The Page (Document)
The offsetX Property The target Element
The offsetY Property The target Element

See Also:

The Mouse Event Object



Syntax

event.pageY

Technical Details

Return Value: A Number.
The Y (vertical) pixel coordinate of the mouse pointer.
DOM Version: DOM Level 4 Mouse Events.

More Examples

Example

The coordinates of the mouse pointer while the mouse pointer moves:

let x = event.pageX;
let y = event.pageY; 
Try it Yourself »

Example

The differences between pageX and pageY and screenX and screenY:

let pX = event.pageX;
let pY = event.pageY;
let sX = event.screenX;
let sY = event.screenY;
Try it Yourself »

Browser Support

event.pageY is a DOM Level 4 (2015) feature.

It is supported in all modern browsers:

Chrome Edge Firefox Safari Opera
Yes Yes Yes Yes Yes

event.pageY is not supported in Internet Explorer 11 (or earlier).