Header. Same buttons with different links on different pages.

I have invisible strip with buttons in header which is visible when I scroll it down. Main header turns into local header actually. And In local header I have button which should be connected to local (only on this page) anchors.
When I click the button on first page inside local header it scrolls correctly, but when I go to another page with its own local header and click the button on that header I go back to first page anchor.

Here is example page of my WIP website.
https://www.dia-interactive.com/360-online-tour

How can I have different functions on buttons in header depending on which page is opened?

Thank you in advance!