Looking for a button to go back to previous page

braincandydan
Visitor
1 0 1

I am trying to create a button that will return the user back to the previous page that they came from. I have tried: 

<a href="javascript&colon;history.go(-1)">Click here to go back to previous page</a>

but for some reason it does not work. 

Anyone have any ideas on how to get something like this working?

 

Replies 3 (3)

iDoThemes
Trailblazer
207 43 91

You could try putting your JS inside the onclick="" attribute instead of the href="" one.

 

Probably better to use a button in this case instead of an anchor:

<button onclick="history.go(-1)">Click here to back to previous page</button>

 

Developer of Liquify Chrome Extension -- Enhance the Shopify Theme Code Editor
.




Theme Developer -- Drop me a line
Andre_Borges
Excursionist
32 0 12

No one gave you the credit but it works!!!

Thanks

@iDoThemes

littlecornerhom
Visitor
1 0 0

Where should I place the coding in Shopify? Thanks so much.