back button link

I wanted to add a link to my site on each page so people can go back.

Is there an easy way to do this?

If someone went through 5 pages, and they hit the link I am going to make, how will I know to go through the 5 pages?

I don't want it to just go to the referrer.

If they go from page 1 to page 2 5 then hit back it should go to page 4, if from there they hit the back button, it should go to the previous one from page 4, which was page 3, not just back to page 5.
Who is Participating?
If you want to go back 1 page, use

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

for your link.  You may also want to consider having "forward" links as well, and for those, you would use

<a href="javascript:history.forward();">Forward</a>
or <a href="javascript:history.go(1);">Forward</a>

I may have misinterpereted you but it sounds like you want to go all the way to the first page in the history as well?  For that just use
<a href="javascript:history.go(-(history.length));>Go to the beginning</a>
Try using this  in your back link and change the -1 to -5 or whatever depending on the amount of pages you want to go back:

<a href="Javascript:history.go(-1)">Back</a>
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.