Name
History: the URL history of the browser â JavaScript 1.0: Object â History
Synopsis
window
.history
history
Properties
-
length
This numeric property specifies the number of URLs in the browserâs history list. Since there is no way to determine the index of the currently displayed document within this list, knowing the size of this list is not particularly helpful.
Methods
-
back( )
Goes backward to a previously visited URL.
-
forward( )
Goes forward to a previously visited URL.
-
go( )
Goes to a previously visited URL.
Description
The History object was originally designed to represent the browsing
history of a window. For privacy reasons, however, the
History object no longer allows scripted access to the actual URLs
that have been visited. The only functionality that remains is in
the use of the back( )
, forward( )
, and go( )
methods.
Example
The following line performs the same action as clicking a browserâs Back button:
history.back( );
The following line performs the same action as clicking the Back button twice:
history.go(-2);
See Also
The history
property of the
Window
object, Location
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.