Categories:

JavaScript Kit > JavaScript Reference > Here

History

Last updated: June 20th, 2004

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

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

Methods

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).

Examples

go(whereTo)

<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>


Reference List

Partners
Right column

CopyRight 1998-2014 JavaScript Kit. NO PART may be reproduced without author's permission.