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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:32:47+00:00 2026-05-27T00:32:47+00:00

I have an issue with .scrollTop() I have a page that stores the current

  • 0

I have an issue with .scrollTop()

I have a page that stores the current scrollTop() position in session when unloading.
My goal is that when I come back to this page, the page scrolls until the last scrollTop position I had on it.

My JS code is simple :

console.log('=>'+parseInt(scrollto)+' '+parseInt($(window).scrollTop())); 
$(window).scrollTop(scrollto);
console.log('=>'+parseInt(scrollto)+' '+parseInt($(window).scrollTop()));

Result in my browser’s console :

=> 2500 0
=> 2500 2500

Ok, my page is scrolled at the exact last postion.

The issue comes with big values of scrollto variable.
This is what I’ve got in console :

=> 12352 0
=> 12352 7683

I don’t get why it is not scrolling at the requested position

I’ve even tried this :

var max_times= 10;

for(var i=0;i<max_times;i++){
console.log('=>'+parseInt(scrollto)+' '+parseInt($(window).scrollTop()));
if (parseInt(scrollto) > parseInt($(window).scrollTop())) 
    $(window).scrollTop(scrollto);
}

And result :

=> 13450 0
=> 13450 7985
=> 13450 7985
=> 13450 7985
...
=> 13450 7985

Other info :

  • I have the same result on Chrome and Safari.
  • The page I’m talking about contains a lot of images so it takes some
    time to be fully loaded.

I would really appreciate any help.

Thank you.

  • 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-05-27T00:32:47+00:00Added an answer on May 27, 2026 at 12:32 am

    Ok.

    I’ve found a solution that works.

    Thanks for your hints guys, the total height of the page had to be involved.

    What I’ve done is that :

    var timer = setInterval(function(){
        if ((parseInt(scrollto) > parseInt($(window).scrollTop())) && (parseInt($(document).height())>parseInt(scrollto))){
           $(window).scrollTop(scrollto);
           if ($(window).scrollTop()>=scrollto)
               clearInterval(timer);    
        }
    },500);
    
    setTimeout(function(){clearInterval(timer);},10000);
    

    I set a interval that checks if the total height of the page is enough to scroll to the requested position each 500ms. If it’s the case, it scrolls. If the position is OK, then we clear the interval.

    If none of this works, the interval is cleared after 10s.

    Thanks again for helping me out with this !

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

Sidebar

Related Questions

I have function that scrolls to a anchor position in a list function snapToAnchor(anchor)
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue that is driving me a bit nuts: Using a UserProfileManager
We have an issue on our page whereby the first time a button posts
I have an issue with watin test that should browse for pdf and upload
Here is my current situation: I have a web page containing a couple scrollable
I have this code: if (Page.IsPostBack) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), Javascript, alert('test');jQuery('html, body').animate({ scrollTop: jQuery('.newslettersubscribe').position().top },
so I have a page that has a fixed link bar on the side.
i have done drag and drop using with jquery. here i have issue that
I have issue with a value that should have just work, however, it seem

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.