[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/API/Window/scrollY [Back]  [Original]

Window.scrollY - API | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Window.scrollY

Baseline Widely available *

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..

* Some parts of this feature may have varying levels of support.

scrollY Window. , . , . , scrollX.

In this article

var y = window.scrollY

, , , , . , . Y, scrollY = 0.

: , Math.round() .

, scrollY Y- (viewport). , = 0.

js
//      
if (window.scrollY) {
  window.scroll(0, 0); //        .
}

window.scrollByPages(1);

, , , scrollBy(), scrollByLines(), or scrollByPages().

pageYOffset - scrollY :

window.pageYOffset == window.scrollY; //  

- window.pageYOffset window.scrollY. , Internet Explorer (<9) . Internet Explorer . :

js
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
CSSOM View Module
# dom-window-scrolly


Web Proxy Viewer  |  New URL  |  Original Page