Robino Posted January 22, 2020 Share Posted January 22, 2020 I installed an anchor link on my homepage in Squarespace 7.1 and when i click the link it jumps to the section instead of scrolling down to it. I'm using a CODE block with a DIV ID in the section I want to scroll to. see code below: <div id="pp"></div> and for the text link I put: /homepage/#pp It doesn't scroll, it just loads the section that has the Code Block with ID. Any help is appreciated. Thx Link to comment
Robino Posted January 22, 2020 Author Share Posted January 22, 2020 Update - just chatted with support and the agent said that anchor links are not supported in 7.1 It's strange, such a basic functionality. If anyone know of a workaround please share, thx very much todd-y 1 Link to comment
Robino Posted January 26, 2020 Author Share Posted January 26, 2020 Update #2 Ok I got it working. This is how you add Smooth scrolling anchor links in Squarespace 7.1 This works in all browsers including mobile. ------------------------------------------------------------------------------------------------------------ 1. Insert this code in the HEADER CODE INJECTION <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> <script src="https://unpkg.com/smoothscroll-polyfill/dist/smoothscroll.min.js"></script> <script src="https://unpkg.com/smoothscroll-anchor-polyfill"></script> 2. Insert this code in CUSTOM CSS html { --scroll-behavior: smooth; scroll-behavior: smooth; } 3. Create your anchor links. You will need to get the PAGE SECTION ID for the section you would want to anchor to. It looks like this: #page-section-5e2799dfc3035b3cf9e9c4d6 I have a hard time finding those IDs so what I do is right-click and inspect the section I want to anchor to and I do a search in the console and type: ID. Then you should be able to easily find all the page IDs. Once you have your page ID, you can create text links or buttons, whatever links you want and just put the # sign before the ID so it looks like this: #page-section-5e2799dfc3035b3cf9e9c4d6 That's it - smooth scrolling in all browsers and mobile. Note that in Chrome it will smooth scroll to a CODE BLOCK when using regular CODE block DIV IDs but it won't work in SAFARI / iPHONEs Mobile. Only the #page-sectionIDs work in all browsers. DPruitt, MichaelS, mrsbrightseid and 7 others 3 6 1 Link to comment
sarahcreates Posted January 29, 2020 Share Posted January 29, 2020 This doesn't work for me unfortunately. Still trying to find a solution to anchor links. So frustrating! Link to comment
Robino Posted February 3, 2020 Author Share Posted February 3, 2020 On 1/29/2020 at 3:46 AM, sarahcreates said: This doesn't work for me unfortunately. Still trying to find a solution to anchor links. So frustrating! Ah that sucks, I wonder why it's not working for you. I just re-tested on my website to make sure Squarespace didn't update something that broke my solution and it is still working. Make sure you use page sections and that you don't have any other css code related to page scrolling that might be interfering with the code above. Link to comment
hellojquinn Posted February 8, 2020 Share Posted February 8, 2020 Worked for me! Thanks Robino. One thing though - I couldn't easily find the page ID by clicking 'inspect'... So I just right clicked and went to View Frame Source, ctrl F to find the section I was aiming for, for example Contact Us section, so I typed in 'contact', and it brought me to the section where I found the page section. Copied the page section ID, put a hashtag in the link for my contact us button, and it works! Thanks a heap. Link to comment
maldrich Posted February 19, 2020 Share Posted February 19, 2020 This works! Thank you so much! Link to comment
wholeheartcreative Posted February 24, 2020 Share Posted February 24, 2020 Hi guys, which much digging I found a solution that enables it to work on chrome! Thanks to another thread by @orangechandesign: https://forum.squarespace.com/topic/152386-anchor-links-do-not-work-correctly-on-mobile/#comment-335263 ❤️ Works great on 7.1. Link to comment
Kate Posted March 23, 2020 Share Posted March 23, 2020 We have a really simple add-on for anchor linking in 7.1 -- https://www.squareaddons.com/shop-2/anchor-linking If you are looking for a way to add Anchor Links, Gallery Blocks, or a Rotating Banner with Content Blocks overlaid in Squarespace 7.1, you can find all these plugins in our Squarespace add-on store here: www.Squareaddons.com -- Enjoy! Link to comment
theresa.southern Posted July 14, 2020 Share Posted July 14, 2020 @Kate We bought your plugin and it does not work any better for us than putting the anchor links in the normal way 😞 I submitted a support ticket but hey, if you are around and want to help 🙂 Link to comment
rwp Posted July 14, 2020 Share Posted July 14, 2020 @theresa.southern I am finalizing an anchor link code for 7.1 that I have been working on for a while. I think I have it almost done. Link to comment
rwp Posted July 14, 2020 Share Posted July 14, 2020 @theresa.southern Please see here and PM me if you think this might help you. Link to comment
MichaelS Posted February 18, 2021 Share Posted February 18, 2021 (edited) Robino, this DID work, so thank you for the hard work. It seems like this should not be a difficult cross-browser problem for Squarespace to solve, but without having attempted to solve it myself, I am aware it could be more difficult than it appears. Thank you. Edited February 18, 2021 by MichaelS Link to comment
epergaboni Posted June 15, 2021 Share Posted June 15, 2021 (edited) place this on your Header <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> <script type="text/javascript"> $(function() { $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top }, 1000); return false; } } }); }); </script> Place This on your CSS html { scroll-behavior: smooth; } Edited June 15, 2021 by epergaboni bpc 1 Link to comment
bpc Posted June 29, 2021 Share Posted June 29, 2021 @epergaboni The code works on desktop but when viewing in mobile it locks up the navigation. Any suggestions on how to fix it? Link to comment
tuanphan Posted July 1, 2021 Share Posted July 1, 2021 On 6/29/2021 at 10:31 AM, bpc said: @epergaboni The code works on desktop but when viewing in mobile it locks up the navigation. Any suggestions on how to fix it? What is your site url? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
bpc Posted July 1, 2021 Share Posted July 1, 2021 13 hours ago, tuanphan said: What is your site url? Never mind. It seems to be working now. Thanks for your help though! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment