鼠标移动事件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Pirates Booty</title> <script> window.onload = init; function init(){ var map = document.getElementById("map"); map.onmousemove = showCoords; } function showCoords(eventObj){ var map = document.getElementById("coords"); x = eventObj.clientX; y = eventObj.clientY; map.innerHTML = "Map coordinates: " + x + "," + y; } </script> </head> <body> <img id="map" src="map.jpg"> <p id="coords">Move mouse to find coordinate..</p> </body> </html>