Probá así:
Código PHP:
<!DOCTYPE HTML>
<html>
<head>
<title>poscion</title>
<meta charset="utf-8">
<script>
function raton(e) {
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY) {
posx = e.pageX;
posy = e.pageY;
} else if (e.clientX || e.clientY) {
posx = e.clientX;
posy = e.clientY;
}
return {x:posx,y:posy}
}
document.onmousemove = function(e){
document.getElementById('mosPos').innerHTML = raton(e).x;
};
</script>
</head>
<body><div id="mosPos" style="background:red"> </div></body>
</html>