Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!