源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <script type="text/javascript"> function coordinates(event){ x=event.screenX y=event.screenY alert("X=" + x + " Y=" + y) } </script> </head> <body onmousedown="coordinates(event)"> <p> 在文檔中點擊某個位置。消息框會提示出指針相對於屏幕的 x 和 y 坐標。 </p> </body> </html>
運行結果