historyNN 2 IE 3 DOM n/a  

  

During a browser session, the browser uses the history object to maintain a list of URLs visited by the user. This list (stored as an array) is used by the browser to assist with navigation via the Back and Forward buttons. Due to the sensitive nature of the private information stored in the history object, not many of the details are exposed to scripts that could capture such information and surreptitiously submit it to a server. In more recent browser versions, each window maintains its own history object.

 

To answer a frequently-asked question: no, you cannot block or disable the Back button's action. At most, you can prevent the current page from being entered into the browser's history when a user clicks on a link from the page. Accomplish this by scripting the links with the location.replace( ) navigation method. Navigator 4 and later (with signed scripts and the user's explicit approval) can remove the toolbar from the browser window (see the locationbar object discussion). Or, you can open a new window without the toolbar (see the window.open( ) method).

 
Object Model Reference
 
[window.]history
 
Object-Specific Properties
 
currentlengthnextprevious
 
Object-Specific Methods
 
back( )forward( )go( )item( )
 
Object-Specific Event Handler Properties

None.

lengthNN 2 IE 3 DOM n/a  

Read-only  

The number of items in the history list. Even with this information, you are not allowed to extract a specific history entry except with signed scripts and the user's permission in Navigator 4 or later.

 
Example
 
if (history.length > 4) {
    ...
}
 
Value

Integer.

 
Default

None.

back( )NN 2 IE 3 DOM n/a  

  

The basic action is to navigate to the previously viewed document, similar to the click of the browser's Back button. In Navigator 4 or later, however, you can direct the back( ) method to a specific window or frame, thus bypassing the default behavior of the Back button. For example, repeated calls to parent.otherFrame.history.back( ) eventually run out of history for the frame and then cease to do anything further. On the other hand, repeated calls to top.history.back( ) are the same as clicking the Back button, conceivably backing out of the frameset entirely if it wasn't the first document loaded in the current browser session.

 
Parameters

None.

 
Returned Value

None.

forward( )NN 2 IE 3 DOM n/a  

  

The basic action is to navigate to the same URL that the browser's Forward button leads to (if it is active). Similar cautions about the window's history from the history.back( ) method apply here, as well.

 
Parameters

None.

 
Returned Value

None.

go( )NN 2 IE 3 DOM n/a  

go(stepCount | "URL")

  

Navigates to a specific position in the history listing.

 
Parameters
 
  • An integer representing how many items away from the current listing the browser should use to navigate. A value of zero causes the current page to reload; a value of -1 is the same as back( ); a value of -2 is the URL two steps back from the current item in history. A bug in IE 3 causes all values other than 0 to be treated as -1.
  • A URL or (in Navigator) document title stored in the history listing.
 
Returned Value

None.

item( )NN 4 IE n/a DOM n/a  

item(itemNumber)

  

Returns the URL at a specific location in the history list. Requires Netscape signed scripts and the user's explicit permission to retrieve this private information.

 
Parameters
 
  • An integer representing the number of item within the history list. The range of acceptable values is 0 through the history.length minus 1.
 
Returned Value

URL String.