Hey friends, needing some quick help here. I’m attempting to place smooth scroll links to various sections inside my site – this can be done either through Page Section links that have an ID, or placing the #IDNAME as the URL for Link Blocks.
Webflow has built in smooth scrolling – this is great. However with all the page jumps I have inside my site, I need to remove the #hash from showing up in the browser URL bar. This is to prevent poor user experience, i.e. a user clicks around the page 5 times… this in turn requires 6 clicks to the browser back button to actually go back a page.
Any help with a quick script I can add to my site to leave the smooth scrolling as is, but prevent all hash links from landing in the URL bar of the browser? Happy to Venmo/CashApp anyone $5 that can solve this for me lol. I am out of answers!
1.) You will need to replace “your-class” with whatever class the links are. For these links hrefs too, put in a hashtag followed by the ID of the section it should scroll to.
3.) If you have a fixed navbar, you can also replace the “92” with the height in pixels of your nav.
4.) Then you should wrap this in script tags and place before the closing body tag.
If you need help implementing this let me know and I can assist further.
I unfortunately was unable to utilize your instructions to get this to work. I’m honestly not sure what I’m doing wrong, so if you have a site I can use as a reference point, or really any visual assistance, I think that would be the most helpful.
Hey! I know it has been a while but it still does not work for me…
I have anchors all over my page and none of them is inside a navbar.
If I now paste your following one-liner into my custom-code head:
I tried Jordan’s fix, and it did remove the #anchor link from the browser URL when an anchor link is clicked. However, it looks like the change in URL still posted to the page history somehow, as the browser back button still doesn’t work as expected: clicking the browser back button doesn’t change the page appearance at all, indicating that the history is still “stuck” on the anchor tag. Example: the in-page links at Volunteer Design Leadership