代码示例:(标识:eg_js_events_screenxy)
<!DOCTYPE html>
<html>
<head>
<script>
function coordinates(event) {
  document.getElementById("demo").innerHTML = "X = " + event.screenX + "<br>Y = " + event.screenY;
}
</script>
</head>
<body>

<img src ="/static/demo/images/eg_planets.jpg" alt="Planets" 
onmousedown="coordinates(event)" />

<p>单击上面的图片可显示鼠标指针相对于屏幕的 x 和 y 坐标。</p>

<p id="demo"></p>

</body>
</html>
运行结果: