Help solve the problem of scrolling to anchors

Hello!
The essence of the problem:
I have on the site in the top menu there is a link of the following form “http://example.com/#services”.

If I’m on the main page of the site, then it works fine.

But if I’m on any other page, nothing happens when I click on a link.

I need to make it so that on the main page, when you click on this link, you start scrolling to the anchor, and if I’m on another page of the site, you should go to the main page to the specified anchor.

I found “// Anchorscroll” in scripts.js, but since I’m not a programmer, it’s hard for me to understand what needs to be added (changed).

Hello,

Are you sure that you have http://example.com/#services there and not just #services?

Kind Regards, Roman.

Yes, look at the screenshot:

1

The link is full, not just the anchor. I checked it first :slight_smile:

My point of view is how to solve this problem:
It is necessary to prescribe an additional condition that will check which page I am at the moment. If the main one page is - scrolling, and if on any other page - then the transition will be performed.

That’s just how I prescribe it, I do not know)))

I’m sure that the problem is related to “// Anchorscroll” in scripts.js (scripts.min.js), because if commenting out this function, the link is working, but there is no smooth scrolling.

Okay, you can try to install Surbma – Smooth Scroll plugin:

Please feel free to ask any other questions that you might have.

Kind Regards, Roman.

1 Like