Navigate through the user's history backward or forward in JavaScript

Description

The following code shows how to navigate through the user's history backward or forward.

Example


<!--from w  ww . j a va2s . c  o  m-->
<!DOCTYPE HTML>
<html>
<body>
<script>
history.go(-1);


</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Navigate through the user
Home »
  Javascript Tutorial »
    Browser »
      Browser History
Javascript Tutorial Browser History
Add an Entry to the Browser History with hi...
Go one step back with history.back() in Jav...
Go one step forward with history.forward() ...
Navigate through the user's history backwar...
Navigate to the first location in history t...
Tell how many items are in the history stac...