Search code examples
javascriptjqueryjquery-pluginssmooth-scrolling

Using jQuery-Smooth-Scroll from one page to another?


I am currently using jQuery-Smooth-Scroll to smoothly scroll up and down to various anchor positions on one of my pages (Page 1). However, what I would also like to be able to do is, from another page (Page 2), link to Page1 (appending #bookmark to the url) and have jQuery-Smooth-Scroll pick up on the fact I am calling the page with a #bookmark and have it smoothly scroll down to the relevant position once the page has completed loading. I don't know if this is a possibility or not?

This is the version of Smooth-Scroll that I'm using:

https://github.com/kswedberg/jquery-smooth-scroll

I'm still relatively new to jQuery so I may be overlooking something obvious.


Solution

  • It's possible, you want to put a call into the smooth scroll function when the page is finished loading. in jQuery, it's using $(document).ready(function () { your code } );

    You'll need to put something in to parse your url to extract the #bookmark and then call the smooth scroll.