MouseEventscreenX Property
Example
The coordinates of the mouse pointer when the mouse button is clicked:
let x = event.screenX; // Horizontal
let y = event.screenY; // Vertical
Try it Yourself »let y = event.screenY; // Vertical
More examples below.
Description
ThescreenX property returns thehorizontal screen coordinate of the mouse pointer when a mouse event is triggered.
ThescreenX property is read-only.
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:
Syntax
event.screenX
Technical Details
| Return Value: | A Number The horizontal screen pixel coordinate of the mouse pointer |
|---|---|
| DOM Version: | DOM Level 2Mouse Events |
More Examples
Example
The differences between screenX and screenY and clientX and clientY:
let sX = event.screenX;
let sY = event.screenY;
let cX = event.clientX;
let cY = event.clientY;
Try it Yourself »let sY = event.screenY;
let cX = event.clientX;
let cY = event.clientY;
Browser Support
event.screenX is a DOM Level 2 (2001) feature.
It is fully supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera | IE |
| Yes | Yes | Yes | Yes | Yes | 9-11 |

