Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8699093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:51:50+00:00 2026-06-13T01:51:50+00:00

I am trying to make the page display in the browser AFTER it has

  • 0

I am trying to make the page display in the browser AFTER it has fully loaded AND jumped to the scroll offset position defined in the scrollBy function. How can that effect be achieved?

Most solutions I’ve seen on the web is to hide/show the elements on “onload”. But I cant seem to get it work when offset is used.

For example, I’ve tried a couple of things so far. In the example code given change the visibility value to visible after the scrollby function has run. But for some reason the scrollby function always seems to be run last, resulting in that the page is displayed at top and immediately jumps to the offset.

Other variations I’ve tried is using “display: block” and using a overlay div which covers the whole page, which is later removed with javascript. But the result is the same, the scrollby function always seems to be run last – regardless of the order in the “goToByScroll” function.

function goToByScroll()
{
    window.scrollBy(0,300); // Jumps to specific offset

    document.getElementById("page").style.visibility="visible"; 
}
window.onload = goToByScroll;   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:51:52+00:00Added an answer on June 13, 2026 at 1:51 am

    You need to give control back to the browser in between setting the scroll position and applying the new style. Simple edit:

    function goToByScroll()
    {
        window.scrollBy(0,300); // Jumps to specific offset
    
        setTimeout('document.getElementById("page").style.visibility="visible"', 0); 
    }
    window.onload = goToByScroll;
    

    Otherwise, the order in which your DOM changes will be applied by the browser is non-deterministic.

    Whilst JavaScript code is being executed, the browser will not apply updates to the DOM; Imagine iterating through a large table, applying formatting to every cell, the author will usually want all those changes to appear instantaneously.

    The browser only applies updates to the DOM when JavaScript is idle (waiting for another event, for example). setTimeout is one way to delay processing and allow the browser to apply any changes made so far.

    However, setTimeout will create a new execution context, so you won’t be able to access variables local to the function. Ideally, you should only call zero-argument functions with setTimeout, otherwise it’s just another evil eval statement:

    function goToByScroll()
    {
        window.scrollBy(0,300); // Jumps to specific offset
        setTimeout(showPage, 0);
    }
    
    function showPage()
    {
        document.getElementById("page").style.visibility="visible"; 
    }
    
    window.onload = goToByScroll;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make web page which would display two other webpages side
trying to make a page which will recursively call a function until a limit
I'm trying to make a page for a photo story - it's meant to
I'm trying to make a page with some Points in it. E.g: Point1 Point2
I am trying to make a page where users can add as many rows
Here is jsfiddle ! I am trying to make user page where he can
I'm trying to make a status page on my app. This page should show
I was trying to make a one page script with the action set to
So I'm trying to make a registration page that feeds back a variable when
I'm trying to make a login page using html, ajax & ASP.NET.The data is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.