Scroll to anchor in different (and the same) page


I was looking for a script to implement an anchor link to a different url with a smooth scroll effect.

I have tested different solutions and I like the script here

The example here

It works fine, but the problem is that I have a second listing of links in page2, pointing at anchors also in the same page2, and then the smooth effect does not work since you are not linking to a third page but to an anchor in the same one.

The script:

    var jump=function(e)
       if (e){
           var target = $(this).attr("href");
           var target = location.hash;

           scrollTop: $(target).offset().top
           location.hash = target;


    $('html, body').hide()

        $('a[href^=#]').bind("click", jump);

        if (location.hash){
                $('html, body').scrollTop(0).show()
            }, 0);
          $('html, body').show()

Is it possible to modify this script to get the same effect when linking to the same page? Or am I wasting my time with it?

Thanks very much.

I have been tested the script with an htacess redirection and I see that it is a question of page loading or reset.

I mean that if you are on the page1 and click on a link to an anchor in page2, it works, but not if you set that same link on page2 and then click on it. You go to the anchor in page2, but the smooth scroll does not work.

If you rename the link on page2 and set a redirection to the correct one to the anchor on that same page, it works because the link leads you out of the page and then in again (so to speak) through the redirection.

The question is that I have to set too many links to use this trick, and would like to ask whether there might be a way to refresh or reload (???) the page after clicking on that link on page2 to the anchor on page2.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.