document.documentElement.scrollTop return value differs in Chrome

Viewed 42520

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 returns '0'. Do i need to do anything to overcome this issue?

FF:

>>> document.documentElement.scrollTop
342

Chrome:

document.documentElement.scrollTop
0
6 Answers

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

This happens when using the Safari version 13 or the lower version. Please update your Safari browser to 14 or higher.

Related