IE8 alternative to window.scrollY?

前端 未结 8 909
一向
一向 2020-11-29 06:02

I\'m trying to determine how many pixels down I\'ve scrolled using window.scrollY. But this isn\'t supported in IE8. What is the safe, cross-browser alternative

8条回答
  •  旧时难觅i
    2020-11-29 06:22

    If you don't have to use it a lot, just do:

    var scroll = window.scrollY //Modern Way (Chrome, Firefox) 
    || document.documentElement.scrollTop (Old IE, 6,7,8)
    

提交回复
热议问题