<html> <head> <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 somewhere in the document. An alert box will alert the x and y coordinates of the cursor, relative to the screen. </p> </body> </html>
Your Result:
Edit the code above and click to see the result.
W3Schools.com
- Try it yourself