当前位置:网站首页>图解事件坐标screenX、clientX、pageX, offsetX的区别
图解事件坐标screenX、clientX、pageX, offsetX的区别
2022-07-01 06:29:00 【song854601134】
图解事件坐标screenX、clientX、pageX, offsetX的区别
一、图解

如图所示,假设页面中灰色圆点是鼠标点击处,黄色区域是鼠标触发事件对象
二、概念
1、screenX 和screenY
- 参照点:电脑屏幕左上角
- screenX:鼠标点击位置相对于电脑屏幕左上角的水平偏移量
- screenY:鼠标点击位置相对于电脑屏幕左上角的垂直偏移量
2、clientX和clientY
- 参照点:浏览器内容区域左上角
- clientX:鼠标点击位置相对于浏览器可视区域的水平偏移量(不会计算水平滚动的距离)
- clientY:鼠标点击位置相对于浏览器可视区域的垂直偏移量(不会计算垂直滚动条的距离)
3、pageX和pageY
- 参照点:网页的左上角
- pageX:鼠标点击位置相对于网页左上角的水平偏移量,也就是clientX加上水平滚动条的距离
- pageY:鼠标点击位置相对于网页左上角的垂直平偏移量,也就是clientY加上垂直滚动条的距离
4、offsetX和offsetY
- offsetX:鼠标点击位置相对于触发事件对象的水平距离
- offsetY:鼠标点击位置相对于触发事件对象的垂直距离
三、事件对象参数

边栏推荐
- 解决The code generator has deoptimised the styling of xxxx.js as it exceeds the max of 500kb
- 虚幻 简单的屏幕雨滴后处理效果
- [summary of knowledge points] chi square distribution, t distribution, F distribution
- Internet worm
- lxml模块(数据提取)
- [unity shader custom material panel part I]
- Teach you how to implement a deep learning framework
- H5网页判断是否安装了某个APP,安装则跳转未安装则下载的方案总结
- 三分钟带你快速了解网站开发的整个流程
- SQL学习笔记九种连接2
猜你喜欢
随机推荐
[self use of advanced mathematics in postgraduate entrance examination] advanced mathematics Chapter 1 thinking map in basic stage
[summary of problem thinking] Why is the register reset performed in user mode?
Redis安装到Windows系统上的详细步骤
10 golang operator
ManageEngine Zhuohao helps you comply with ISO 20000 standard (IV)
脏读、幻读和不可重复读
Free trial of self-developed software noisecreater1.1
问题:OfficeException: failed to start and connect(二)
三说 拷贝构造之禁用
微信公众号内嵌跳转微信小程序方案总结
[ManageEngine] how to realize network automatic operation and maintenance
Although pycharm is marked with red in the run-time search path, it does not affect the execution of the program
SQL语句
【微信小程序】如何搭积木式开发?
Record MySQL troubleshooting caused by disk sector damage
H5网页判断是否安装了某个APP,安装则跳转未安装则下载的方案总结
[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
Lxml module (data extraction)
DSBridge
PAT (Advanced Level) Practice 1057 Stack
![[unity shader stroke effect _ case sharing first]](/img/bd/5cd1bef24e6b6378854114c2c05bd9.png)
![阿里OSS Postman Invalid according to Policy: Policy Condition failed: [“starts-with“, “$key“, “test/“]](/img/3c/7684b7c594f7871471f89007294703.png)







