<a href="javascript:history.back();">Previous Page</a>
Don't use the JavaScript pseudo-protocol when you don't need to. Consider
what will happen when JavaScript is disabled.
To the OP:
Creating your own "Back" link that doesn't go to a fixed location can be a
bad idea. For a couple of reasons:
- If the user has JavaScript disabled, your link will do absolutely
nothing and frustrate the user.
- If the user goes directly to the page (from their history, or a
bookmark), going "back" is meaningless and it makes your site unnavigable.
I come across this frequently, and it's very annoying.
If the user wants to go back through their history, let them use the
appropriate button. However, if you insist on creating your own link, use:
<a href="anActualPage.html" onclick="window.history.back(); return
false">Back</a>
You'll have to choose a sensible location for "anActualPage.html", which
should be a common root for all of the possible referring pages (like the
main site page). Note that this solution will still leave the second
problem above unresolved. Only a fixed address, with no JavaScript
interrupting the link, can solve it.
Mike