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

边栏推荐
- Pol8901 LVDS to Mipi DSI supports rotating image processing chip
- 【微信小程序低代码开发】二,在实操中化解小程序的代码组成
- 华福证券开户是安全可靠的么?怎么开华福证券账户
- 问题:OfficeException: failed to start and connect(三)
- Student attendance system for C language course (big homework)
- How does the port scanning tool help enterprises?
- webapck打包原理--启动过程分析
- C language course set up library information management system (big homework)
- Grain Mall - environment (p1-p27)
- [unity shader custom material panel part I]
猜你喜欢

Discrimination between left and right limits of derivatives and left and right derivatives

SQL语句

Some pits designed by NOC

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

【#Unity Shader#Amplify Shader Editor(ASE)_第九篇】

Design of sales management system for C language course (big homework)
![[wechat applet] view container and basic content components](/img/25/181986ab4bf048854d1d1ca87de637.jpg)
[wechat applet] view container and basic content components

虚幻 简单的屏幕雨滴后处理效果

【微信小程序】如何搭积木式开发?

B-tree series
随机推荐
证券类开户有什么影响 开户安全吗
虚幻 简单的屏幕雨滴后处理效果
JSON module
MySQL learning
Resttemplate use
华福证券开户是安全可靠的么?怎么开华福证券账户
B-tree series
libpng12.so. 0: cannot open shared object file: no such file or directory
产品学习(三)——需求列表
【#Unity Shader#Amplify Shader Editor(ASE)_第九篇】
存储函数学习笔记
数据库笔记
SQL中DML语句(数据操作语言)
[ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security
根据输入画有向图
绕圆旋转动画组件,拿过来直接用
【Unity Shader 描边效果_案例分享第一篇】
C language course set up library information management system (big homework)
Interview questions for HW (OD) post
C语言课设学生选修课程系统(大作业)