Buenas, aquí mi código:
<!DOCTYPE html>
<html><head><title>Ejemplo aprenderaprogramar.com</title><meta charset="utf-8">
<style>
#area{
width:500px;
height:400px;
position: relative;
}
</style>
<script type="text/javascript">
function start(){
document.getElementById('area').addEventListener('mouseout', function(){
document.getElementById('x').innerHTML = '-';
document.getElementById('y').innerHTML = '-';
});
}
function getCoordenadas(event){
var area = document.getElementById('area');
document.getElementById('x').innerHTML = event.pageX;
document.getElementById('y').innerHTML = event.pageY;
}
</script>
</head>
<body onload="start()">
<h1>Posición x: <span id="x">-</span> Posición y: <span id="y">-</span></h1>
<div id="area" onmousemove="getCoordenadas(event)"></div>
</body>
</html>