var Cursor_X; var Cursor_Y; document.addEventListener('mousemove', onMouseUpdate, false); document.addEventListener('mouseenter', onMouseUpdate, false); function onMouseUpdate(e){ Cursor_X = e.pageX; Cursor_Y = e.pageY; }