29

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...

Sonia Brami
  • 127
  • 1
  • 1
  • 10
greg_bor
  • 301
  • 1
  • 3
  • 9
  • Possible duplicate of [IE8 alternative to window.scrollY?](https://stackoverflow.com/questions/16618785/ie8-alternative-to-window-scrolly) – zuluk Jun 26 '17 at 10:55
  • Just because the specification says one is an alias of the other, does not necessarily mean that browsers will have implemented it according to specification ... – CBroe Jun 26 '17 at 11:31
  • OK but is it possible that IE has a function that looks the same as alias in specification but works in other way - surprisingly work, in opposite to the alias with the same name... – greg_bor Jun 26 '17 at 11:40

1 Answers1

51

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.

Balder
  • 621
  • 5
  • 4