MouseEvent screenY Property

Definition and Usage

The screenY property returns the vertical coordinate of the mouse pointer (relative to the user's computer screen) at the time of the event trigger.

Tip:To get the horizontal coordinate of the mouse pointer (relative to the user's computer screen), use screenX Attribute.

Note:This property is read-only.

Instance

Example 1

Get the mouse pointer's coordinates relative to the screen when the mouse button is clicked on an element:

var x = event.screenX;     // Get the horizontal coordinate
var y = event.screenY;     // Get the vertical coordinate
var coor = "X coords: " + x + ", Y coords: " + y;

Try It Yourself

Example 2

Demonstrate the difference between clientX and clientY as well as screenX and screenY:

var cX = event.clientX;
var sX = event.screenX;
var cY = event.clientY;
var sY = event.screenY;
var coords1 = "client - X: " + cX + ", Y coords: " + cY;
var coords2 = "screen - X: " + sX + ", Y coords: " + sY;

Try It Yourself

Syntax

event.screenY

Technical Details

Return value: Number value, representing the vertical coordinate of the mouse pointer, in pixels.
DOM Version: DOM Level 2 Events

Browser Support

Atribute Chrome IE Firefox Safari Opera
screenY Suporta Suporta Suporta Suporta Suporta

Relatibong Pahina

HTML DOM Reference Manual:MouseEvent screenX Atribute

HTML DOM Reference Manual:MouseEvent clientX Atribute

HTML DOM Reference Manual:MouseEvent clientY Atribute

HTML DOM Reference Manual:MouseEvent offsetX Atribute

HTML DOM Reference Manual:MouseEvent offsetY Atribute