You can make use of the 'devicePixelRatio property' which should solve your issue when a user zoom their page -
Window: devicePixelRatio property[
^]
I made a fiddle that seems to work irrespective of zoom percentage -
[
^]
I used the code inside the body element with 'document.onclick' to call the function also inside the body element -
<html>
<head>
<title>Mouse Click Position</title>
</head>
<body>
<p>
Hi
</p>
<script>
function getMousePosition(event) {
const zoomLevel = window.devicePixelRatio || 1;
let x = event.clientX / zoomLevel;
let y = event.clientY / zoomLevel;
alert("Mouse Click Position - X: " + x + ", Y: " + y);
}
document.onclick = getMousePosition;
</script>
</body>
</html>