HTML and CSS Reference
In-Depth Information
Table 6-1.
Properties an
d Methods of the
History
Object
Property / Method
Description
length
Indicates the number of entries in the
History
object.
back()
Takes a user to the previous URL in the history.
forward()
Takes a user to the next URL in the history.
go()
Takes a user to a specified URL in the history. The
go()
method takes a single
parameter that can be either a number or a URL string. If the parameter is a
number, the user is taken to a URL at that specific position with respect to the
current page. A negative number indicates movement backward through the
history, and a positive number indicates movement forward through the history .
For example,
window.history.go(-2)
takes the user two pages backward relative to
the current page. If the parameter is a URL, the user is navigated to that URL.
Developers don't use the
History
object very often because users most commonly use the browser's
back and forward buttons to navigate the history. However, if required for some reason, the properties and
methods described in Table 6-1 are available to programmatically navigate to history entries.
To demonstrate the use of the
History
object, let's develop a simple Slide Show application in ASP.NET
MVC. The Slide Show application displays images of some carpentry tools along with their descriptions, as
shown in Figure 6-1.
Figure 6-1.
User interface of the Slide Show application