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

157
Vistas
Scrolling a document to the far right on load

I can't figure this out, sounds like it should be simple but I tried all kinds of variations of what I found here javascript - How to use window.scroll to automatically scroll on pageload? - Stack Overflow but trying to modify it to scroll horizontally instead... and couldn't get any of them to work. If I used code to scroll to the bottom, that worked fine.

I'm trying to run the code within

$(function () {
    function Scrolldown() {
        // alert("hi")
       //$("img").scrollIntoView(false);
    //    window.scrollTo({ left: 0, top: document.body.scrollHeight, behavior: "smooth" });
        // window.scrollTo(-5000, 0);
//        $("img").scrollIntoView(false);
   }
   
   window.onload = Scrolldown; 
});

My page simply consists of a bunch of images, all the same width.. which are wider than the view area (or whatever the technical term is) of the browser... i.e. you need to scroll right to see the rest of the image.

I would like on load for the user to see the right end of the image, the left part can be off-screen. As opposed to the default where the left is visible and the right is offscreen.

I'm not averse to animation, but without is preferable. But the important thing is just finding something that works.

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

0

This seems to do the trick for me:

window.addEventListener('load', (event) => {
  setTimeout(() => {
    window.scrollTo({
      left: window.innerWidth,
      behavior: 'smooth',
    });
  }, 0);
});

So I guess you can adapt it to fit your code like so:

$(function () {
  function Scrollright() {
    setTimeout(() => {
      window.scrollTo({
        left: window.innerWidth,
        behavior: 'smooth',
      });
    }, 0);
  }
   
   window.onload = Scrollright; 
});
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