Jump to content

Auto scroll to a section on the page after first landing

Go to solution Solved by Beyondspace,

Recommended Posts

Posted

Site URL: https://www.smoredate.com/

Once the web page loads, I want to automatically jump to a section on the home page without using anchor links or having to press a button/click a link. I created a redirect using div as below:

<div id="scroll-here">

</div> 

It takes you to the Home page on the navigation bar with the anchor tag in the url slug--> /home#scroll-here

Then I set up a script in the landing page where I want the auto scroll to work:

<script>
var url= "https://www.smoredate.com/home#scroll-here";
     window.location = url;

</script>

The code works on the front end but Squarespace dashboard never stops loading, I'm assuming it's jumping between the two home pages: the one on the navigation bar and the landing home page! Where did I go wrong?! :(

  • Solution
Posted
2 hours ago, saj_3472 said:

Site URL: https://www.smoredate.com/

Once the web page loads, I want to automatically jump to a section on the home page without using anchor links or having to press a button/click a link. I created a redirect using div as below:

<div id="scroll-here">

</div> 

It takes you to the Home page on the navigation bar with the anchor tag in the url slug--> /home#scroll-here

Then I set up a script in the landing page where I want the auto scroll to work:

<script>
var url= "https://www.smoredate.com/home#scroll-here";
     window.location = url;

</script>

The code works on the front end but Squarespace dashboard never stops loading, I'm assuming it's jumping between the two home pages: the one on the navigation bar and the landing home page! Where did I go wrong?! 😞

Try settings hash url only

location.hash = "#scroll-here"

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - PDF Lightbox popup - ...) </>  🗓️ Delivery Date Picker (Date picker form field)
Gallery block 7.1 workaround </> No-code customisations for Squarespace

  • 2 years later...
Posted

Could someone walk me through this, please? I can't tell what you're suggesting to do instead. Talk to me like I'm 5. I put the anchor in the section, right? Then where do I put the other code and how should it look. I tried a few things with my limited understanding. Thanks. 

Posted
On 1/5/2024 at 4:16 AM, JesseBiltz said:

Could someone walk me through this, please? I can't tell what you're suggesting to do instead. Talk to me like I'm 5. I put the anchor in the section, right? Then where do I put the other code and how should it look. I tried a few things with my limited understanding. Thanks. 

With script code, you can add it to Website Tools (under Not Linked navigation) > Code Injection > Scroll down to Footer box

image.png.f48a35ee325113155fe7d2ea72834c37.png

image.png.f937b50646580edd7f1fc74d6c6633ed.png

image.png.b5906f2373d994e5e7fd964ad244c017.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

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.