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

边栏推荐
- 常用快捷键
- 软件工程复习
- What is a port scanning tool? What is the use of port scanning tools
- C#如何打印輸出原版數組
- Dongle data collection
- Code power is full of quantitative learning | how to find a suitable financial announcement in the financial report
- 关于变量是否线程安全的问题
- [ManageEngine] how to realize network automatic operation and maintenance
- C language course is provided with employee information management system (large operation)
- Promise
猜你喜欢

C语言课设学生选修课程系统(大作业)
![[self use of advanced mathematics in postgraduate entrance examination] advanced mathematics Chapter 1 thinking map in basic stage](/img/54/f187e22ad69f3985d30376bad1fa03.png)
[self use of advanced mathematics in postgraduate entrance examination] advanced mathematics Chapter 1 thinking map in basic stage
![[wechat applet] to solve button, input and image components](/img/7f/a61ee2f610b2f0f9fb0b34cb960f81.jpg)
[wechat applet] to solve button, input and image components

async 与 await

【微信小程序低代码开发】二,在实操中化解小程序的代码组成

mysql学习

嵌入式系统
![[unity shader custom material panel part II]](/img/d1/8632ae680299a27b7431b2d6e03fd3.png)
[unity shader custom material panel part II]

Redis安装到Windows系统上的详细步骤
![[ManageEngine] how to realize network automatic operation and maintenance](/img/8a/75332d3180f92c6a6482d881032bbf.png)
[ManageEngine] how to realize network automatic operation and maintenance
随机推荐
[wechat applet] how to build a building block development?
C how to print out the original array
【Unity Shader 描边效果_案例分享第一篇】
Design of sales management system for C language course (big homework)
数据库对象:视图学习记录
Forkjoin and stream flow test
【微信小程序低代码开发】二,在实操中化解小程序的代码组成
数据库笔记
PAT (Advanced Level) Practice 1057 Stack
根据输入画有向图
What are the functions of LAN monitoring software
给逆序对数求原数组
Lxml module (data extraction)
Dongle data collection
Picture server project test
C language course set up student elective course system (big homework)
Idea easy to use plug-in summary!!!
[ManageEngine Zhuohao] mobile terminal management solution, helping the digital transformation of Zhongzhou aviation industry
Comment imprimer le tableau original
Rotate the animation component around the circle, take it and use it directly