Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

108
Vistas
How do I keep the scroll bar at the same place is was before I left the website? Is it even possible?

My goal is that whenever the user closes and comes back to the website it recognizes where he/she was and automatically goes back to the topic the user was reading.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There may be a simpler way to do this, but this is the way I found most intuitive.

document.addEventListener("DOMContentLoaded", () => {
  // document has been loaded!
  if (localStorage.getItem("scrollY") !== null)
    window.scrollTo(0, localStorage.getItem("scrollY"));
});

document.addEventListener("scroll", () => {
  // user scrolled!
  localStorage.setItem("scrollY", window.scrollY);
});
  • You have the DOMContentLoaded event to the scroll on page load to the last position
  • You have the scroll event to update the scroll position in localStorage.
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda