From 1109132f09d75da9a28b649c7677bb6ce07c40c0 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:45 -0500 Subject: initial commit --- files/es/web/api/window/scrolly/index.html | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 files/es/web/api/window/scrolly/index.html (limited to 'files/es/web/api/window/scrolly') diff --git a/files/es/web/api/window/scrolly/index.html b/files/es/web/api/window/scrolly/index.html new file mode 100644 index 0000000000..81b8275746 --- /dev/null +++ b/files/es/web/api/window/scrolly/index.html @@ -0,0 +1,61 @@ +--- +title: Window.scrollY +slug: Web/API/Window/scrollY +tags: + - API + - Propiedad + - Rerencia + - Scroll Vertical +translation_of: Web/API/Window/scrollY +--- +
{{APIRef}}
+ +

Sumario

+ +

Retorna el número de píxeles que han sido desplazados en el documento mediante el scroll vertical.

+ +

Sintaxis

+ +
var y = window.scrollY;
+ + + +

Ejemplo

+ +
// Asegurate de bajar a la segunda página
+if (window.scrollY) {
+  window.scroll(0, 0);  // Restablece la posición de desplazamiento en la parte superior izquierda del documento
+}
+
+window.scrollByPages(1);
+ +

Notas

+ +

Usa esta propiedad para verificar que al documento no se le ha hecho scroll, si estás usando funciones relativas de scroll como {{domxref("window.scrollBy")}}, {{domxref("window.scrollByLines")}}, o {{domxref("window.scrollByPages")}}.

+ +

La propiedad pageYOffset es un alias para la propiedad scrollY:

+ +
window.pageYOffset == window.scrollY; // Siempre verdadero
+ +

Para compatibilidad entre navegadores, es recomendable usar window.pageYOffset en vez de window.scrollY. Adicionalmente, tener en cuenta que versiones más viejas de Internet Explorer (<9) no soportan del todo la propiedad y debe ser solucionado usando propiedades no estandarizadas . Un ejemplo totalmente compatible entre navegadores:

+ +
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;
+
+ +

Especificación

+ + + +

Ver también

+ + -- cgit v1.2.3-54-g00ecf