0

I know how to animate scroll on a link on the same page. I know also how to jquery page scroll from an external page. The problem is that I need to use the same hash link to animate from an external page and internal page as well.

Let me explain further

Suppose I have three links,

Link A Link B-1 Link B-2

and link B-1 and B-2 are on the same page and in succeeding divs. I'm currently in Link A and when I click Link B-2, it should go to the page where Links B-1 and B-2 are and animate scroll to the area where Link B-2 is. If I click Link B-1 while on the same page, it should animate scroll back to the top.

Same thing should happen if I was on Link A's page and I clicked on B-1, it should go to the page where B-1 and B-2 is and animate scroll into B-1's section. If I click B-2 on the same page, it should animate scroll into that section.

Does this make sense? Can anyone help me with this please? Thank you

anon
  • 1
  • 3

1 Answers1

0

If you have access to source code of external link, you can pass variable by set cookie in browser. and get this cookie when you reach external link. In cookie you will put value like scrollToBlock = b2. and when you get this value from cookie on external link enter, you will know where to scroll.

You can read about cookies here: Set cookie and get cookie with JavaScript

Community
  • 1
  • 1
freethinker
  • 2,257
  • 4
  • 26
  • 49