Jump to content

Anchor links not working on mobile site

Recommended Posts

I have anchors in place on my home page so that when someone clicks on links at the top, they are redirected further down the page. These work well on desktop, but are not working for mobile devices. When someone clicks on the links on a mobile device, they are just bounced back to the top of the page. Please Help!

Link to comment
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...
On 10/4/2023 at 7:11 PM, Kayley said:

Restorehopear.org

You try adding this to Website Tools (under Not Linked) > Code Injection > Footer

<!-- by @nhannhot-tuanphan -->
<!-- fix anchor links on iOS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(() => {
function scrollToAnchor(aid){
    var aTag = $(aid);
    $('html,body').animate({scrollTop: aTag.offset().top},'slow');
}

scrollToAnchor(location.hash);
})
</script>

 

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.