Ken Ward's Java Script Tutorial ...

Back and Forward Buttons using History

This page is the first in a series addressing navigation. It uses history to navigate from one page to another. Other page in this series are:

Back and Forward Buttons (Simple)
Back and Forward Buttons
Back and Forward Buttons 2

The following form buttons go to the next or previous page in history, as appropriate. They act just like the back and forward buttons on the browser. I don't see much use for them but sometimes the user might prefer to use the page to navigate than to use the browser. It seems more professional to do this!

I don't see much use for them because they just duplicate the browser's button. And it is better to send the reader to a specific page than to sent him or her back in history. Sometimes, they are appropriate, however.

 

Here is the code for the form:

<FORM>
<INPUT TYPE="button" VALUE="<< Back" onClick="Back1()">
<INPUT TYPE="
button" VALUE="Forward >>" onClick="Forward1()">
</FORM>

Here is the script:

<script LANGUAGE="JavaScript">
<!--//
function
Back()
{
history.go(
-1);
}
function
Forward()
{
history.go(
+1);
}
-->
</script>

The script uses the simple 'history.go()' with values for +1 (forward) and -1 (backwards).

 


Ken Ward's HTML Guide...


[If you need to learn more about HTML visit the HTML Tutorial]

To ask questions, make comments, etc,

And for some programming for your brain: check out New Life Course