The onmousemove event

The onmousemove event is triggered whenever a visitor to your page moves their mouse. In this example, the user gets the feeling that someone’s watching their every move (Figure 9.5). Scripts 9.10, 9.11, and 9.12 show how to use JavaScript to display eyeballs that follow your visitor around.

Figure 9.5. The eyeballs will follow the cursor, no matter where it goes.
1.
document.onmousemove = moveHandler;
For all browsers, if a mousemove event is triggered, call the moveHandler() function.
2.
function moveHandler(evt) {
  if (!evt) {
     evt = window.event;
  }
  animateEyes(evt.clientX,evt.clientY);
}
The moveHandler() ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.