HTML and CSS Reference
The history object is a property of the window object. It keeps track of the pages (in a
to move back or forward on a page, similar to the back button and forward button sup-
ported by your browser. The history object can reference only those pages that have been
visited; that is, those pages on its stack. It has a length property and three methods called
go() , back() , and forward() . See Tables 10.15 and 10.16.
Table 10.15 Properties of the history Object
What It Describes in the URL
The current document URL.
The number of entries in the history object.
The URL of the next document in the
The URL of the previous document in the
The query string.
Table 10.16 Methods of the history Object
What It Does
Goes to the previous URL entry in the history list; like the browser's back
Goes to the next URL entry in the history list; like the browser's forward
The browser will go forward or back (if the value is negative) the
number of specified pages in the history object.
// Go back three pages
// Go forward three pages
// Same as history.go(-1)
// Same as history.go(1)