screenYEvent Property
Event Object
Definition and Usage
The screenY event property can return the vertical coordinate of the mouse pointer relative to the screen when an event occurs.
Syntax
event.screenY
Example
Example
The following example shows the coordinates of the mouse pointer when an event occurs:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script type="text/javascript">
function coordinates(event){
x=event.screenX
y=event.screenY
alert("X=" + x + " Y=" + y)
}
</script>
</head>
<body onmousedown="coordinates(event)">
<p>
Click a location in the document. A message box will display the x and y coordinates of the pointer relative to the screen.
</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script type="text/javascript">
function coordinates(event){
x=event.screenX
y=event.screenY
alert("X=" + x + " Y=" + y)
}
</script>
</head>
<body onmousedown="coordinates(event)">
<p>
Click a location in the document. A message box will display the x and y coordinates of the pointer relative to the screen.
</p>
</body>
</html>
Try it Yourself »
Event Object Other Extensions