Window.scrollY does not show the correct top-scroll value on IE11 but Window.pageYOffset, the alias of Window.scrollY, works as expected. I find confusing the fact that the alias works better than the original property. Could somebody help me understand why? :[
Note - I'm not interested in finding a cross-browser compatible version. The point is that I want to know why an alias on IE11 is not working the same as the value which is being "tracked". I'm not sure if I should deeply focus on some different "aliases" on IE...
The read-only Window property pageYOffset is an alias for scrollY ; as such, it returns the number of pixels the document is currently scrolled along the vertical axis (that is, up or down) with a value of 0.0, indicating that the top edge of the Document is currently aligned with the top edge of the window's content ...
Definition and UsageThe scrollY property returns the pixels a document has scrolled from the upper left corner of the window. The scrollY property is read-only.
scrollX. The read-only scrollX property of the Window interface returns the number of pixels that the document is currently scrolled horizontally. This value is subpixel precise in modern browsers, meaning that it isn't necessarily a whole number.
Window.scrollY is not supported in IE(11 or below). Window.pageYOffset works on "all" browsers including IE9-11. Window.scrollY works on "all" browsers except IE.
IE9 and below should (in most cases) not be supported anymore because using them means no security updates for browser or OS, but IE8 alternative to window.scrollY? explains you can use document.documentElement.scrollTop
for lower versions of IE.
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