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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:33:01+00:00 2026-05-31T19:33:01+00:00

I was trying to use jQuery’s page scroll inside some pages and could successfully

  • 0

I was trying to use jQuery’s page scroll inside some pages and could successfully make a smooth page scroll. The only problem I have now is when attempting to do that from different page. What I mean by that is if I click on a link in a page, it should load the new page and then scroll to the specific div element.

Here is the code I used to scrolling inside the page:

var jump=function(e)
{
       //prevent the "normal" behaviour which would be a "hard" jump
       e.preventDefault();
   //Get the target
   var target = $(this).attr("href");
   //perform animated scrolling
   $('html,body').animate(
   {
           //get top-position of target-element and set it as scroll target
           scrollTop: $(target).offset().top
   //scrolldelay: 2 seconds
   },2000,function()
   {
           //attach the hash (#jumptarget) to the pageurl
           location.hash = target;
   });

}

$(document).ready(function()
{
       $('a[href*=#]').bind("click", jump);
       return false;
});

I hope the idea is clear.

Thanks

Very important Note:
This code I posted above works great inside the same page, but what I’m after is to click a link from one page and go to another one and then scroll to the target. I hope it is clear now. Thanks

  • 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-31T19:33:02+00:00Added an answer on May 31, 2026 at 7:33 pm

    You basically need to do this:

    • include the target hash into the link pointing to the other page (href="other_page.html#section")
    • in your ready handler clear the hard jump scroll normally dictated by the hash and as soon as possible scroll the page back to the top and call jump() – you’ll need to do this asynchronously
    • in jump() if no event is given, make location.hash the target
    • also this technique might not catch the jump in time, so you’ll better hide the html,body right away and show it back once you scrolled it back to zero

    This is your code with the above added:

    var jump=function(e)
    {
       if (e){
           e.preventDefault();
           var target = $(this).attr("href");
       }else{
           var target = location.hash;
       }
    
       $('html,body').animate(
       {
           scrollTop: $(target).offset().top
       },2000,function()
       {
           location.hash = target;
       });
    
    }
    
    $('html, body').hide();
    
    $(document).ready(function()
    {
        $('a[href^=#]').bind("click", jump);
    
        if (location.hash){
            setTimeout(function(){
                $('html, body').scrollTop(0).show();
                jump();
            }, 0);
        }else{
            $('html, body').show();
        }
    });
    

    Verified working in Chrome/Safari, Firefox and Opera. I don’t know about IE though.

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

Sidebar

Related Questions

I'm trying to use jQuery to make a slightly more sophisticated page refresh. With
I'm trying to use jQuery UI tabs much like a Master Page in ASP.Net.
I am trying to use JQuery to submit a form without reloading the page.
im trying to use jquery bbq for remembering page with ajax. but i wonder,
I am trying to use jquery delegate to bind to scroll events. html <div
I am trying to use jquery to find a div inside an iframe. Is
I am trying to use jQuery's fancy autocomplete function but I have a problem
Trying to use JQuery to scroll through a ul li list using class next
im trying to use jquery in order to make a button remove its parent
I'm trying to use jQuery.post() function to retrieve some data. But i get no

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.