THE HISTORY OBJECT
The history
object represents the user's navigation history since the given window was first used. Because history
is a property of window
, each browser window
object has its own history
object relating specifically to that instance. For security reasons, it's not possible to determine the URLs that the user has visited. It is possible, however, to navigate backwards and forwards through the list of places the user has been without knowing the exact URL.
Navigation
The go()
method navigates through the user's history in either direction, backward or forward. This method accepts a single argument, which is an integer representing the number of pages to go backward or forward. A negative number moves backward in history (similar to clicking the browser's Back button), and a positive number moves forward (similar to clicking the browser's Forward button). Here's an example:
// go back one page
history.go(-1);
// go forward one page...