Jump to content

Help with a simple code to add a "go back" button.

Recommended Posts

Hi.

I am in the process of making a simple website with some products and I wish to have a text-line or a button at the top of the every product page, where if you click or press it, you go back to your browsers previous page.
Like the go back arrow button in your browser.


I found some code you can put in the "Code injection" in the Header section, which add a text to the top of the product page, but it only allows for navigating to a specific page. Are there any generous person in here who like to dedicate a little time to help me with the correct code for such a task. I would be very grateful.  

 

The code I found looks like this:

Quote

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
   jQuery(document).ready(function($) { 
   $('<a href="/shop" class="back-to">Gå tilbage</a>').appendTo("nav.ProductItem-nav");
 }); 
</script>

 

Edited by Dan_Hansen
Link to comment
  • Dan_Hansen changed the title to Help with a simple code to add a "go back" button.
  • Replies 7
  • Views 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

Posted (edited)
21 hours ago, tuanphan said:

I used to help a member to do this on standard page, if you share link to a product, I will try adjust that code for your case

Thank you for your attention. The page isn't public yet, and it's yet to get the domain and DNS connected. So I am not sure what I can post that will help you?

In any case, I imagine all that will be needed is something put into the "header" section?
I want to "go back" the be present on all products, since the navigation disappears on the mobile version of the page and I am not sure if iPhone users will have an easy time going back to previous page.

Edited by Dan_Hansen
Link to comment
On 3/3/2024 at 2:01 PM, Dan_Hansen said:

Thank you for your attention. The page isn't public yet, and it's yet to get the domain and DNS connected. So I am not sure what I can post that will help you?

In any case, I imagine all that will be needed is something put into the "header" section?
I want to "go back" the be present on all products, since the navigation disappears on the mobile version of the page and I am not sure if iPhone users will have an easy time going back to previous page.

You can follow this guide to share url (you can use built-in Squarespace url)

 

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!)

Link to comment
13 hours ago, tuanphan said:

You can follow this guide to share url (you can use built-in Squarespace url)

 

Is it possible to work out a code without having to publish the whole page? I though code could be made without having to publish an unfished site to the whole world? I appreciate your time, but I can't justify publishing the site in this sate.

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.