The history object stores locations of prior web pages visited.
Code:
<script type="text/javascript">
//<![CDATA[
document.write("history.length is the number of pages currently in history: " + history.length + "<br /><br />");
document.write("<a href='#' onclick='javascript:history.back()'>history.back()</a> is the same as clicking the back button.<br /><br />");
document.write("<a href='#' onclick='javascript:history.forward()'>history.forward()</a> is the same as clicking the forward button.<br /><br />");
//]]>
</script>
Output: