<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body {
font-family: "Microsoft YaHei", serif;
}
body, dl, dd, p, h1, h2, h3, h4, h5, h6 {
margin: 0;
}
ol, ul, li {
margin: 0;
padding: 0;
list-style: none;
}
img {
border: none
}
#wrap{
position: absolute;
top: 100px;
left: 100px;
width: 100px;
height: 100px;
background-color: #cc3366;
}
</style>
</head>
<body>
<div id="wrap"></div>
<script>
let oWrap = document.getElementById("wrap");
oWrap.onclick = function (ev) {
console.log(ev);
// 都不兼容ie
// 事件触发的时候 鼠标距离可视区的位置
console.log(ev.clientX);
console.log(ev.clientY);
// 事件触发的时候 鼠标距离文档的位置
console.log(ev.pageX);
console.log(ev.pageY);
// 事件触发时鼠标位置距离事件主体的距离
console.log(ev.offsetX);
console.log(ev.offsetY);
// 事件触发时鼠标位置距离屏幕的距离
console.log(ev.screenX);
console.log(ev.screenY);
}
</script>
</body>
</html>
Python3Turtle