How do I create a back button?

That’s it really…

Drag in a button, create a class, customize it… Then go to the settings, link in page, and then select the page you want it to go back to.

Hope this helps. :wink::+1:

Unfortunately, we cannot use javascript:history.back(1); directly as the link in the element settings.

The next alternative is custom code. There are two ways, inline and page/sitewide.

Inline:

Add an embed component to the page and paste this:

<a href="javascript:history.back(1);" class="w-button">Back Button</a>

Sitewide

Paste this in Site Settings > Custom Code > Footer Code

<script>
var Webflow = Webflow || [];
Webflow.push(function() {
  $('a.back-button').click(function() {
    history.back(1); return false;
  });
});
</script>

Now give a class back-button to all the links or buttons that you want to trigger a back button action.

Publish and view the site in your web browser (this doesn’t work in your designer preview)

14 Likes

Thanks, but this is back from a collection template page so I don’t know where the user has come from.

1 Like

Worked perfectly, thanks

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.