var element = document.createElement('div'); document.body.appendChild(element); document.onmousemove = function(event){ event = event || event.window; element.innerHTML = event.clientX; };