title: vertical document scroll position in JavaScript that is cross-browser compatible up to IE 8
body: <p>I am wanting the scroll position of the document element in JavaScript, since I cannot use jQuery.</p>
  
  <p><strong>Question</strong>: What would be the JavaScript code for getting the document's vertical scroll position?  I need to make it compatible as far back as IE 8 and all modern browsers. </p>
  
  <p><strong>UPDATE 1</strong>: 
  I reviewed the 2 answers given as duplicates of this. The first one does address my problem though its not focusing on a cross-browser solution, but the second one is way off what I need. I need the vertical scroll position of document and not scrolling to the top of document. The second post talks about using a link or going step by step to top of document, which does not address my question.</p>
  
  <p><strong>UPDATE 2</strong>:
  Based on the answer provided by minitech, I came up with following functions to determine scroll positions that works across all modern browsers as well as upto IE 8. I tested this and it worked in Chrome, FireFox, Opera, Edge , IE 8, IE 9, IE 10 and IE 11.</p>
  
  <pre><code>function getScrollY() {
          return  window.scrollY || window.pageYOffset || document.body.scrollTop;
  }
  
  function getScrollX() {
      return window.scrollX || window.pageXOffset || document.body.scrollLeft;
  }
  </code></pre>