document.documentElement.scrollTop return value differs in Chrome

后端 未结 5 1274
既然无缘
既然无缘 2020-12-03 02:52

I am trying to process some code based on the \'document.documentElement.scrollTop\' value. It returns \'348\' in FF and IE but in Chrome it return

5条回答
  •  误落风尘
    2020-12-03 03:27

    You can use this function document.body.getBoundingClientRect() and it returns this object {x: 0, y: 0, width: 1903, height: 2691.5625, top: 0, …}; in this object you can access body top document.body.getBoundingClientRect().top

提交回复
热议问题