<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mouse Coordinates</title>
<style>
#coordinates {
position: fixed;
top: 10px;
left: 10px;
background-color: rgba(0, 0, 0, 0.5);
color: white;
padding: 5px;
border-radius: 5px;
}
</style>
</head>
<body>
<div id="coordinates"></div>
<script>
document.addEventListener("DOMContentLoaded", function() {
const coordinatesDiv = document.getElementById('coordinates');
function updateCoordinates(event) {
const localX = event.clientX;
const localY = event.clientY;
const globalX = event.pageX;
const globalY = event.pageY;
coordinatesDiv.innerText = `Local: (${localX}, ${localY}) Global: (${globalX}, ${globalY})`;
}
document.addEventListener('mousemove', updateCoordinates);
});
</script>
</body>
</html>