运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body onclick="showCoords(event)" style="border:1px solid black;padding:4px"> <h1>Mouse Events</h1> <h2>The pageX and PageY Properties</h2> <div> <p>Click anywhere in this document to show the x and y coordinates of the mouse pointer.</p> <p id="demo"></p> </div> <script> function showCoords(event) { let pX = event.pageX; let pY = event.pageY; let sX = event.screenX; let sY = event.screenY; let coords1 = "pageX: " + pX + ", pageY: " + pY; let coords2 = "screenX: " + sX + ", screenY: " + sY; document.getElementById("demo").innerHTML = coords1 + "<br>" + coords2; } </script> </body> </html>