How to add the path of an anchor to the page address

Asked

Viewed 28 times

1

I created an onepage, used anchors and id to do the internal navigation. I need at the end of the site url to be shown which part of the site is being displayed.

Example: When accessing the site this url is loaded: www.meusite.com/index.html

When clicking on the "contact" link, I need this to be increased in the address, thus: www.meusite.com/index.html#contact

I’m using

<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="#contato">Contato</a>

<section class="page-section contato" id="contato">
  • It seems to be correct. What problem are you having?

  • I need the id to be added to the page address, but when I click on any anchor link, the site address remains the same. When I click on "contact" the site address is still "domain.com/index.html" and I need it to be "domain.com/index.html#contact"

  • That’s exactly what I need, but it doesn’t change here.

  • I managed to resolve, I removed the js-scroll-Trigger class.

  • Thanks for the help, it’s just a test site to do some tagging through the GTM, the way it’s already capturing what I needed. This js-scroll-trigge is a script to smooth the scrolling of the page, at the moment do not need it, if I change the js.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.