Send user back to previous page with text link

  • 5 February 2018
  • 4 replies
  • 7 views

Badge

I’d like to add a text link on my page that would send the visitor back to their prior page – same functionality as hitting the “back” button in your browser.

I found this old thread, but it’s for adding this functionality to a button, not a text link: Back buttons

Would appreciate any help on how to do this – thanks!


4 replies

Hey @Andy2

The solution given in that thread should still work for your needs! The only thing that you’ll need to change is the selector:

<script>  
jQuery(function() {  
  jQuery("YOUR_TEXT_LINK_ID_HERE").click(function() {  
    history.go(-1);  
    return false;  
  });  
});  
</script>

You can find the selector at the bottom of the Properties panel for the text block that you want to have linked (click the image below to see what I’m talking about):

Let me know if that works out for you. 🙂

Badge

Thank you @leah.ann! For the selector, do I include the pound/hash symbol at the beginning? And, do I keep the quote marks around it?

No problem! And yes to both questions. 🙂 So if I was going to use the selector from the screenshot, the final code would be this:

<script>  
jQuery(function() {  
  jQuery("#lp-pom-text-49").click(function() {  
    history.go(-1);  
    return false;  
  });  
});  
</script>
Badge

Thanks very much, I think I’ve got it!

Reply