JS History Object
CSGNetwork FREE Source Code, Javascript Source, and Code Snippets!
CSGNetwork Custom Search
     Bookmark and Share
Top Free Apps

Right click this window and select "view source" in order to copy the source for this script.


The History object contains an array of previously visited URLs by the visitor. To simulate the browser's back button, for example, you can use the History object:

<a href="javascript:history.go(-1)">Go back</a>


Properties Description
length Returns the number of URLs in the browser's history list.


Methods Description
back() Loads the previous URL in the history list.
forward() Loads the next URL in the history list.
go(whereTo) Goes to a specific URL within the history list. "whereTo" can be an integer to go to a URL within a specific position relative to the current (ie: -1 goes back one page, 1 goes forward one), or a string. For the string, enter a partial or full URL, and the function to match and go to the first URL that matches the string. Example(s).



<a href="javascript:history.go(-3)">Go back 3 pages</a>

<a href="javascript:history.go('javascriptkit.com')">Go to nearest URL in history list with "javascriptkit.com" in the URL.</a>

Bookmark and Share
Registered® Trademark™ and Copyright© 1973 - CSG, Computer Support Group, Inc. and CSGNetwork.Com All Rights Reserved