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

PropertyRelative to
The screenX PropertyThe Screen area
The screenY PropertyThe Screen area
The clientX PropertyThe Window area
The clientY PropertyThe Window area
The pageX PropertyThe Page (Document)
The pageY PropertyThe Page (Document)
The offsetX PropertyThe target Element
The offsetY PropertyThe 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).



Copyright 1999-2023 by Refsnes Data. All Rights Reserved.