-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpagey.js
75 lines (69 loc) · 1.93 KB
/
pagey.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function $(selector) {
return document.querySelector(selector);
}
let tapDom;
window.onload = function () {
tapDom = $('#showPlace');
console.log('tapDom', tapDom);
};
document.onmousemove = function (ev) {
const e = ev || window.event;
console.log('e', e);
const { target } = e;
const rect = target.getBoundingClientRect();
tapDom.innerHTML = `
鼠标事件属性:
<br>
clientX: ${e.clientX}, clientY:${e.clientY}
</br>
x: ${e.x}, y:${e.y}
</br>
screenX:${e.screenX}, screenY:${e.screenY}
</br>
offsetX:${e.offsetX}, offsetY:${e.offsetY}
</br>
pageX:${e.pageX}, pageY:${e.pageY}
<br>
<br>
元素属性:
<br>
clientWidth: ${target.clientWidth}, clientHeight: ${target.clientHeight}
<br>
offsetWidth: ${target.offsetWidth}, offsetHeight: ${target.offsetHeight}
<br>
clientLeft: ${target.clientLeft}, clientTop: ${target.clientTop}
<br>
offsetLeft: ${target.offsetLeft}, offsetTop: ${target.offsetTop}
<br>
scrollWidth: ${target.scrollWidth}, scrollHeight: ${target.scrollHeight}
<br>
<br>
元素 getBoundingClientRect:
<br>
width: ${rect.width}, height: ${rect.height}
<br>
top: ${rect.top}, bottom: ${rect.bottom}
<br>
left: ${rect.left}, right: ${rect.right}
<br>
x: ${rect.x}, y: ${rect.y}
<br>
<br>
window属性:
<br>
window.innerWidth: ${window.innerWidth}, window.innerHeight: ${window.innerHeight}
<br>
window.outerWidth: ${window.outerWidth}, window.outerHeight: ${window.outerHeight}
<br>
window.screenLeft: ${window.screenLeft}, window.screenTop: ${window.screenTop}
<br>
window.screenX: ${window.screenX}, window.screenY: ${window.screenY}
<br>
window.scrollX: ${window.scrollX}, window.scrollY: ${window.scrollY}
`;
};
/* function test(ev) {
var e = ev || window.event;
var div1 = document.getElementById('div1');
div1.innerHTML = "offsetX:"+ e.offsetX +",offsetY : "+ e.offsetY;
}*/