e.pageX,e.offsetX,e.clientX区别e.pageX,e.offsetX,e.clientX区别e.pageX,e.offsetX,e.clientX区别e.pageX,e.offsetX,e.clientX区别e.pageX,e.offsetX,e.clientX区别e.pageX,e.offsetX,e.clientX区别e.pageX,e.offsetX,e.clientX区别
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<style>
div{
margin: 100px;
width: 100px;
height: 100px;
background-color: blue;
}
</style>
<body>
<div></div>
<script>
var div = document.querySelector("div");
div.addEventListener("click",function(e){
console.log("X轴:"+e.pageX+"---Y轴"+e.pageY) //根据页面来计算的坐标
console.log("X轴:"+e.offsetX+"---Y轴"+e.offsetY)//根据盒子来计算坐标的
console.log("X轴:"+e.clientX+"---Y轴"+e.clientY)//浏览器的第一个视角
})
</script>
</body>
</html>