1. Home
  2. Computing & Technology
  3. Personal Web Pages

Create a Back Button
Get a Back Button for Your Web Page

From , former About.com Guide

Guestbook Graphics http://www.bordersetsbyinge.nl/guestbookgraphics1.htm

Create a back button right on your Web page. This button, when clicked, will take the reader back to the page they were on before they came to your page, wherever they came from.

This back button code works just like your browser's back button. It reads from your browser's history and sends the reader back to whence they came.

Basic Back Button Code

The basic code for a back button link is a very simple JavaScript. All you have to do with this back button JavaScript is copy the code and paste it where you want the back button link to show on your Web page.

<a href="javascript:history.go(-1)">Go Back</a>

Use a Button or Image

Maybe instead of using plain text for your back button code you want to use a button image or some other image as your back button. In this case you need to add an image code into the back button code.

The image code replaces the part of the back button code where you see the words Go Back. Just delete Go Back from the back button code and put the image code in it's place.

In the image code below you see http://webserver.com/name_of_graphic.gif. This is where you put the URL (Web address) of the image you want to use for your back button. This is what the image code looks like:

<img src="http://webserver.com/name_of_graphic.gif">

Putting the Code Together

This is what your entire code will look like if you're using a button image or other image for your back button instead of text.

<a href="javascript:history.go(-1)"><img src="http://webserver.com/name_of_graphic.gif"></a>

Explore Personal Web Pages
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Personal Web Pages
  4. Templates, Scripts, Hacks
  5. Scripts: Free Copy & Paste
  6. Create a Back Button - Get a Back Button for Your Web Page>

©2009 About.com, a part of The New York Times Company.

All rights reserved.