history | NN 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 | ||||
|
||||
Object-Specific Methods | ||||
|
||||
Object-Specific Event Handler Properties | ||||
None. |
current, next, previous | NN 4 IE n/a DOM n/a |
Read-only | |
The URL of the current, next, and previous URLs in the history array. This information is private and can be retrieved in Navigator 4 or later only with signed scripts and the user's approval. Signed scripts are beyond the scope of this book, but a good JavaScript book should show you how to create and program signed scripts. |
|
Example | |
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); var prevURL = parent.otherFrame.history.previous; netscape.security.PrivilegeManager.revertPrivilege("UniversalBrowserRead"); |
|
Value | |
URL string. |
|
Default | |
None. |
length | NN 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 | |
|
|
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 | |
|
|
Returned Value | |
URL String. |