var leftToDocument window pageXOffset document documentElement scrollL

1
2
var leftToDocument = window.pageXOffset || document.documentElement.scrollLeft + элемент.getBoundingClientRect().left;
var topToDocument = window.pageYOffset || document.documentElement.scrollTop + элемент.getBoundingClientRect().top;