About js click event, touch the event screen, client

screenX,screenY

clientX, clientY

screen coordinates relative to the upper left corner of the screen, in pixels.

client coordinates relative to the upper left corner of the browser window, in pixels.

 

For example:

When the browser zoom or zoom, screen sends changes, client will not, unless of course you query through the media or otherwise change the elements of the broad higher and so on.

Practice, listening body:

document.body.addEventListener('click',function(e){
console.log('client:',e.clientX);
console.log("sceen:",e.screenX);
}
);

Current page is 100% cases:

Zoom to 110%, where 156 is biased because of personal mouse click, do not be too concerned about. .

You can view, client is not changed, for example you set a div left (of course, absolute positioning for the browser or fixed positioning) to 20px, then regardless of the zoom, clientX are 20px.

Guess you like

Origin www.cnblogs.com/jony-it/p/11240279.html