实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<html><head>
2
<style type="text/css">
3
body
4
{
5
font-size:70%;
6
font-family:verdana,helvetica,arial,sans-serif;
7
}
8
</style>
9
<script>
10
function cnvs_getCoordinates(e)
11
{
12
x=e.clientX;
13
y=e.clientY;
14
document.getElementById("xycoordinates").innerHTML="Coordinates: (" + x + "," + y + ")";
15
}
16
17
function cnvs_clearCoordinates()
18
{
19
document.getElementById("xycoordinates").innerHTML="";
20
}
21
</script>
22
</head><body style="margin:0px;">
23
<div onmouseout="cnvs_clearCoordinates()" onmousemove="cnvs_getCoordinates(event)" style="float:left;width:199px;height:99px;border:1px solid #c3c3c3" id="coordiv"></div>
24
<br>
25
<br>
26
<br>
27
<div id="xycoordinates"></div>
28
29
30
</body></html>