Javascript examples for DOM:Mouse Event
The screenY property returns the vertical coordinate of the mouse pointer.
This property is read-only.
A Number, representing the vertical coordinate of the mouse pointer, in pixels
The following code shows how to get coordinates of the mouse pointer, relative to the screen.
<!DOCTYPE html> <html> <body> <h2 onclick="showCoords(event)">Click this heading</h2> <p id="demo"></p> <script> function showCoords(event) {/* w ww .j av a 2 s. c o m*/ var x = event.screenX; var y = event.screenY; var coords = "X coords: " + x + ", Y coords: " + y document.getElementById("demo").innerHTML = coords; } </script> </body> </html>