g
Printer Friendly Version

editor  
BellaOnline's JavaScript / Java Editor
 

User History and Creating a Back Button

JavaScript is often used to create a back button to go back to the previously viewed page. You will often see something like this at the bottom of a web page:

<- (previous page viewed)  (continuation of content) ->


This can be useful. Often, when you finish reading a web page, your mouse pointer is near the bottom of the window, so being able to navigate from the bottom can be handy. However, before you add a history button, there are several important questions to think about:

What does back mean within the context of your web page?
Where do your readers want to go back to?
Where do you want your readers to go?
Are any or all of these likely to match the url in the browser history?

All too often, I find a really great web page from a web search or link that is obviously part 2 or 3 of a larger series. I see a back button, press it thinking that it will take me back to the previous page in the series and end up back at the previous page in my history. I go back to the page I'm interested in, look around and there is no link to an index or the first page in a series. There is a next or forward button, the mirror image of the one I tried, and it goes to the next page in the series. This is probably a bad use of the history feature.

There are excellent uses of the history feature. If you link difficult or unfamiliar words to a glossary, having a back button after each entry in the glossary could make a lot of sense. You may link to the same glossary item from several different places in your site and people are likely to want to go back to the page they were reading after looking up the term.

Also, you need to remember that it is possible that the URL in the history does not go back to the page that your user was looking at previously. There are several ways to use JavaScript to change the content of the page without changing the URL in the history. If you are using one of these features and want to implement a history features, you will need to implement it yourself. The upside of this is that, unlike the browser history, you are in charge of what is in it. The downside is that it will only work with your site.

Once you decide that you do want to implement a history feature, it is very easy to do. All you have to do is link your image to a URL of the form:

<a href="javascript:window.history.back()">Go Back</a>

Or set an appropriate event to call window.history.back()

This site needs an editor - click to learn more!

JavaScript / Java Site @ BellaOnline
View This Article in Regular Layout

Content copyright © 2013 by Julie L Baumler. All rights reserved.
This content was written by Julie L Baumler. If you wish to use this content in any manner, you need written permission. Contact Editor Wanted for details.



| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2013 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor