• Resolved FrancescoR

    (@francescoitb)


    Hi, is there a way to remove anchor ID from URL? For example when I click on a button to go to #section2, the URL become site.com/#section2. I need the URL to remain always domain only.

    I tried a lot of js snippet, but no one works!

    Sorry my bad English

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi

    Can you please send me a link to your site?

    Thread Starter FrancescoR

    (@francescoitb)

    Hi, thank you for reply! I solved with javascript instead of anchor

    Who need it: just replace “press” with link/button ID and “start” with section/div ID to scroll to

    <script>
        
    scrollTo = (element) => {
      window.scroll({
        behavior: 'smooth',
        left: 0,
        top: element.offsetTop
      });
      console
    }
    
    document.getElementById("press").addEventListener('click', () => {
      scrollTo(document.getElementById("start"));
    });
    </script>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove anchor from URL’ is closed to new replies.