相对于屏幕的光标坐标是什么?
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- function coordinates(event) {
- document.getElementById("demo").innerHTML = "X = " + event.screenX + "<br>Y = " + event.screenY;
- }
- </script>
- </head>
- <body>
- <img src ="/i/eg_planets.jpg" alt="Planets"
- onmousedown="coordinates(event)" />
- <p>单击上面的图片可显示鼠标指针相对于屏幕的 x 和 y 坐标。</p>
- <p id="demo"></p>
- </body>
- </html>