<html>
<body>
<h2 onclick="showCoords(event)">单击此标题可获取单击鼠标指针时的 x(水平)和 y(垂直)坐标。</h2>
<p><b>提示:</b>请尝试单击标题中的不同位置。</p>
<p id="demo"></p>
<script>
function showCoords(event) {
var x = event.clientX;
var y = event.clientY;
var coords = "X coords: " + x + ", Y coords: " + y;
document.getElementById("demo").innerHTML = coords;
}
</script>
</body>
</html>