开发者

Javascript mouse position problem

开发者 https://www.devze.com 2023-01-10 03:44 出处:网络
I am getting the screen coords of my mouse click using clientX and clientY in IE. I am using these coords to plot a point on an openlayers map however, the 开发者_运维知识库x axis is always perfect bu

I am getting the screen coords of my mouse click using clientX and clientY in IE. I am using these coords to plot a point on an openlayers map however, the 开发者_运维知识库x axis is always perfect but the y axis is always exactly 86 pixels out. At the moment I am just getting round this by doing clientY - 86 but obviously this is no good as a long term solution. Does anyone know what/where this 86 is and how I can access the value on the fly?


Javascript uses the top-left corner of the screen as base for positioning.

The x-coordinate is calculated by the distance between the left side of the screen and your pointer

the y-coordinate is calculated by the distance between the top side of the screen and your pointer, because the total amount of pixels your favorites bar, address bar, .. occupies is 86 pixels, this result might seem a bit odd


It seems you are comparing the x/y of mouse in the view area with the actual x/y of the position on screen.

clientX and clientY return the mouse co-ordinates in the viewable browser window, not the users entire screen.

0

精彩评论

暂无评论...
验证码 换一张
取 消