forked from zhangmengxue/Fragment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclientX and clientY.html
56 lines (56 loc) · 1.23 KB
/
clientX and clientY.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>clientX\clientY screenX/screenY example</title>
<style type="text/css">
body{
margin:0;
padding:0;
border:0;
width:1000px;
height:1000px;
border: solid #ef4c6c 5px;
}
label{
display:block;
position:fixed;
}
.one{
left:50px;
top:50px;
}
.two{
left:450px;
top:50px;
}
.three{
left:50px;
top:150px;
}
.four{
left:450px;
top:150px;
}
</style>
</head>
<body onmousedown="showCoords(event)">
<p>点击此框框里的任何地方查看clientX/clientY和screenX/screenY的坐标值:</p>
<label class="one">clientX:<input type="text"/></label>
<label class="two">clientY:<input type="text"/></label>
<label class="three">screenX:<input type="text"/></label>
<label class="four">screenY:<input type="text"/></label>
<script>
function showCoords(event){
var input1 = document.getElementsByTagName('input')[0];
var input2 = document.getElementsByTagName('input')[1];
var input3 = document.getElementsByTagName('input')[2];
var input4 = document.getElementsByTagName('input')[3];
input1.value = event.clientX;
input2.value = event.clientY;
input3.value = event.screenX;
input4.value = event.screenY;
}
</script>
</body>
</html>