X

How To Insert a Back Button in HTML and 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:

<script>
function goBack() { window.history.back() }
</script>

In the BODY section, add the actual back button

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

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.
Varun: Passionate blogger and main author at Techzog.com. Feel free to reach me at techie[at]techzog[dot]com

View Comments (10)

Related Post