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 9250559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:28:16+00:00 2026-06-18T10:28:16+00:00

So, nowadays most browsers will automatically reposition the window scroll on page refresh, which

  • 0

So, nowadays most browsers will automatically reposition the window scroll on page refresh, which is normally great, but I have a situation where I need to reload a page and focus on a different part of the page from where the user left. NOTE the new element which gets focus starts as hidden, so a hash WON’T work. I need to handle it in JS so I can make the div visible, among other things.

called after reload…

$(document).ready(function(){
    $('#mydiv').show();
    var top = $('#myelement').offset().top;
    window.scrollTo(0, top);
});

Nonetheless, the page focuses on the place the user left the page from. After much debugging, it seems to me that the code works well enough, but the browser is handling the reload event AFTER I do, and re-positioning my newly positioned scroll… It happens instantaneously, but if I place an alert just after my scroll, it shows the proper screen location. After dismissing the alert, the browser jumps the scroll back to where IT thinks it should be (at least in Chrome it does).

My question, is there any way to prevent the browser (cross-browser) from handling the reload event? delaying my scroll with a timeout seems to work, but it looks very unprofessional and jumpy.

I’ve tried

    $(document).unbind("scroll"); 

as I saw recommended somewhere here, but it didn’t do anything.

Thanks, in advance, for any help.

  • 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-18T10:28:18+00:00Added an answer on June 18, 2026 at 10:28 am

    Here’s a solution that works in FF (18), Chrome (24) and IE (9).

    Putting the following in a script in the head section of your document:

    function autoScroll() {
        var div = document.getElementById("mydiv");
        div.style.display = '';
        var top = div.offsetTop;
        if(window.scrollTop != top) 
            window.scrollTo(0, top);
    }
    function loadAutoScroll() {
        autoScroll();
        window.onload = null;
        return false;
    }
    function scrollAutoScroll() {
        autoScroll();
        window.setTimeout(function(){ window.onscroll = null; }, 100);
        return false;
    }
    window.onload = loadAutoScroll;
    window.onscroll = scrollAutoScroll;
    

    I’m sure a cleaner solution can be derived.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Actionscript 3, most events use the capture/target/bubble model, which is pretty popular nowadays:
I have been using jQuery 1.23 till now and nowadays most of the plugins
With most of the application servers nowadays have their own connection pools built-in, i.e.
I have a question. Gradually quantum computers will emerge someday. So, nowadays making algorithm
Nowadays most of the Restaurants and other businesses have a Find Locations functionality on
Nowadays we see websites with login form/register form in the home page itself (to
I think every browser has user-controllered full-page zoom nowadays. Is it in anyway accessible
I am starting in node.js unit testing, and I have been investigating which was
Nowadays, Microsoft and Google will index the files on your hard drive so that
Nowadays we have pretty advanced tools to iron out rendering, allowing to see the

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.