当前位置:网站首页>图解事件坐标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:鼠标点击位置相对于触发事件对象的垂直距离
三、事件对象参数

边栏推荐
- High order binary balanced tree
- SQL学习笔记2
- C语言课设销售管理系统设计(大作业)
- 存储函数学习笔记
- On whether variables are thread safe
- Record MySQL troubleshooting caused by disk sector damage
- 伪装请求头库: anti-useragent
- Lxml module (data extraction)
- Resttemplate use
- 阿里OSS Postman Invalid according to Policy: Policy Condition failed: [“starts-with“, “$key“, “test/“]
猜你喜欢

【Unity Shader 消融效果_案例分享】

Lxml module (data extraction)

Free trial of self-developed software noisecreater1.1
![[wechat applet] to solve button, input and image components](/img/7f/a61ee2f610b2f0f9fb0b34cb960f81.jpg)
[wechat applet] to solve button, input and image components
![[ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security](/img/fb/0a9f0ea72efc4785cc21fd0d4830c2.png)
[ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security

On siem

ESP32 ESP-IDF GPIO按键中断响应
![[wechat applet] how to build a building block development?](/img/69/edb02c88b52b474a797307b96de369.jpg)
[wechat applet] how to build a building block development?

C language course is provided with employee information management system (large operation)

【Unity Shader 描边效果_案例分享第一篇】
随机推荐
Forkjoin and stream flow test
[ManageEngine] how to realize network automatic operation and maintenance
Redis安装到Windows系统上的详细步骤
[wechat applet low code development] second, resolve the code composition of the applet in practice
【#Unity Shader#自定义材质面板_第一篇】
json模块
mysql数据类型学习笔记
[ManageEngine Zhuohao] helps Huangshi Aikang hospital realize intelligent batch network equipment configuration management
请求模块(requests)
Mysql 表分区创建方法
C语言课设学生考勤系统(大作业)
[leetcode] day91- duplicate elements exist
What are the functions of LAN monitoring software
[wechat applet] to solve button, input and image components
C language course is provided with employee information management system (large operation)
华福证券开户是安全可靠的么?怎么开华福证券账户
webapck打包原理--启动过程分析
Gson的@JsonAdater注解的几种方式
High order binary balanced tree
[ITSM] what is ITSM and why does it department need ITSM