源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <script> function show_coords(event){ var x=event.clientX; var y=event.clientY; alert("X coords: " + x + ", Y coords: " + y); } </script> </head> <body> <p onmousedown="show_coords(event)">點擊這一行。一個消息框會提示出鼠標指針的 x 和 y 坐標。</p> </body> </html>
運行結果