GIbt die Anzahl an Pixeln zurück, die die Seite vertikal gescrollt wurde.


var y = window.scrollY;
  • y ist die Anzahl der Pixel, wie weit die Seite vertikal gescrollt wurde.


// sei dir sicher und gehe zur 2. Seite 
if (window.scrollY) {
  window.scroll(0, 0);  // reset the scroll position to the top left of the document.



Use this property to check that the document hasn't already been scrolled some if you are using relative scroll functions such as window.scrollBy, window.scrollByLines, or window.scrollByPages.

The pageYOffset property is an alias for the scrollY property:

window.pageYOffset == window.scrollY; // always true

For cross-browser compatibility, use window.pageYOffset instead of window.scrollY. Additionally, older versions of Internet Explorer (< 9) do not support either property and must be worked around by checking other non-standard properties. A fully compatible example:

var supportPageOffset = window.pageXOffset !== undefined;
var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");

var x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft;
var y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;


Specification Status Comment
CSS Object Model (CSSOM) View Module
Die Definition von 'window.scrollY' in dieser Spezifikation.

See also