How To Insert a Back Button in HTML and WordPress

How to Insert Back Button in WordPress

This quick tip shows how to insert a back button in HTML and WordPress which allows your user to navigate to the previous page. This is especially useful if you are developing a tool or a page which contains some user-generated information and you want to go back to the page with the user-generated information retained in the respective input fields.

How To Insert a Back Button in HTML

Simply insert the below code in your HTML file

In the HEAD section, declare the following function:

function goBack() { window.history.back() }

In the BODY section, add the actual back button

<button onclick="goBack()">Go Back</button>

How To Insert a Back Button in WordPress

Simply insert the following code in your WordPress page or post in the Text mode of the editor.

<script>// <![CDATA[
function goBack() { window.history.back() }
// ]]></script>
<button onclick="goBack()">Go Back</button>

Note: When adding the Go Back button in Word press, ensure you hit the Publish or Update buttons directly from the Text Editor mode as the Visual mode removes the onclick attribute of the button.

Let us know if this tip helped you using the comments section below.

You might also want to read up on How to Redirect 404 pages in WordPress, How to reset WordPress password from cPanel and How to Set Up WordPress in a Different Directory.

Comment Policy: Comments adding value to the article are encouraged. Relevant links will be allowed in such comments.
If you think that you have a link that adds value to this article please contact us at techie[at]techzog[dot]com for evaluation of inclusion into the article.
Comments left solely for spamming links will be deleted. Thank you for understanding.

10 thoughts on “How To Insert a Back Button in HTML and WordPress

  1. This does not work in Beaver Builder either.

    WordPress sucks. So does Beaver Builder. None of this simple crap should be this hard and take hours to figure out.

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge

This site uses Akismet to reduce spam. Learn how your comment data is processed.