JavaScript에서 커서의 좌표를 찾으려면 event.screenX를 사용하세요. 및 event.screenY .
예시
다음 코드를 실행하여 JavaScript에서 화면을 기준으로 커서 좌표를 얻을 수 있습니다.
<!DOCTYPE html>
<html>
<head>
<script>
function coordinatesFunc(event) {
document.write("Coordinate(X) = " + event.screenX + "<br>Coordinate(Y) = " + event.screenY);
}
</script>
</head>
<body>
<div onmousedown = "coordinatesFunc(event)">Click me to get coordinates of cursor relative to screen.</p>
</body>
</html>