I want to get screenY when click, but in iOS browser(Edge,Safari...), e.screenY is same as e.pageY.
document.addEventListener('click', e => {
// why are screenY and pageY same?
console.log(e.screenY, e.pageY);
});
I want to get screenY when click, but in iOS browser(Edge,Safari...), e.screenY is same as e.pageY.
document.addEventListener('click', e => {
// why are screenY and pageY same?
console.log(e.screenY, e.pageY);
});
You see, screenY (or better) screenTop is very much different from the pageY.
screenY refers to the number of pixels from the top edge of the browser viewport to the top edge of the screen. MDN Ref.'screenY'
Whereas, pageY refers to the Y coordinate in pixels of the event relative to the whole document also taking into account any vertical scrolling as well. MDN Ref. 'pageY'
So, essentially,
screenY can be used to just know the vertical location of the viewport with respect to the user's screen.
And pageY can be used to get the location of some user event (like 'click' as you suggested or scroll, etc) wrt to the top the the document.
Now as to your query, you must have clicked on the extreme upper border of your viewport, so they can be same in that case.