Are the following methods same?
window.scrollX === window.pageXOffset
window.scrollY === window.pageYOffset
If there is no difference, why two methods are introduced?
From MDN:
The pageXOffset property is an alias for the scrollX property:
window.pageXOffset == window.scrollX; // always true
For cross-browser compatibility, use
window.pageXOffset
instead ofwindow.scrollX
. Additionally, older versions of Internet Explorer (< 9) do not support either property and must be worked around by checking other non-standard properties.
Same thing goes for scrollY
and pageYOffset
.
Source: https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollX
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With