Why is body.scrollTop deprecated?

后端 未结 4 1484
日久生厌
日久生厌 2020-12-01 08:50

It seems body.scrollTop (and body.scrollLeft) are deprecated in ES5 strict-mode. What is the reason for this, given that it still seems okay to use

4条回答
  •  伪装坚强ぢ
    2020-12-01 09:29

    The following code works for me to set the popup in a correct position whenever the click event fires, for all browsers.

    var scrollTop = window.scrollY; //For all browsers.
    var scrollTop = document.body.scrollTop; //This works for only IE Edge specific versions
    

提交回复
热议问题