code: function getPageOffset ( ) {
  
          var supportPageOffset = window.pageXOffset !== undefined,
              isCSS1Compat = ((document.compatMode || "") === "CSS1Compat"),
              x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft,
              y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;
  
          return {
              x: x,
              y: y
          };
      }
docs: https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY#Notes