Blog, Website & Page Publishing

zanders
Member

Anchor Links Not Working In Header Menu Item

SOLVE

When I inspect the URL it is correct, but the link is not clickable on web or mobile. Visit skilltype.com and hover over the How It Works menu items to see what i'm referring to.Screen Shot 2021-09-22 at 11.36.31 AM.png

0 Upvotes
1 Accepted solution
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Anchor Links Not Working In Header Menu Item

SOLVE

Hi @zanders ,

 

It seems that your main.js script is causing an issue. I get the following error in the console when I click on a link:


main.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'top')
at HTMLAnchorElement.<anonymous> (main.js:1)
at HTMLAnchorElement.dispatch (jquery-1.12.4.min.js:3)
at HTMLAnchorElement.r.handle (jquery-1.12.4.min.js:3)

 

Do you have experience in coding? You should remove the faulty function or replace it. `window.scrollTo` could be used instead, you can set the 'behaviour' param to 'smooth' to animate the scrolling.
You could also add smooth-scroll with the following script tag:

<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll@15/dist/smooth-scroll.polyfills.min.js"></script>

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


View solution in original post

1 Reply 1
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Anchor Links Not Working In Header Menu Item

SOLVE

Hi @zanders ,

 

It seems that your main.js script is causing an issue. I get the following error in the console when I click on a link:


main.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'top')
at HTMLAnchorElement.<anonymous> (main.js:1)
at HTMLAnchorElement.dispatch (jquery-1.12.4.min.js:3)
at HTMLAnchorElement.r.handle (jquery-1.12.4.min.js:3)

 

Do you have experience in coding? You should remove the faulty function or replace it. `window.scrollTo` could be used instead, you can set the 'behaviour' param to 'smooth' to animate the scrolling.
You could also add smooth-scroll with the following script tag:

<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll@15/dist/smooth-scroll.polyfills.min.js"></script>

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.