ScreenX event properties

screenX incident attributes The event object

Definitions and usages

The screenX event property returns the horizontal coordinates of the mouse pointer relative to the screen when the event occurred.

Grammar

event.screenX


The following example shows the coordinates of the mouse pointer at the time of the event:

<! DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
Online tutorials for W3Cschool (w3cschool.cn)
<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. The message box prompts for the x and y coordinates of the pointer relative to the screen.
</p>

</body>
</html>

Try it out . . .


screenX incident attributes The event object