Wednesday, November 16, 2005

Client-Side JavaScript Reference
replace
Loads the specified URL over the current history entry.Method of
Location

Implemented in
JavaScript 1.1



Syntax
replace(URL)
Parameters
URL
A string specifying the URL to load.



Description
The replace method loads the specified URL over the current history entry. After calling the replace method, the user cannot navigate to the previous URL by using browser's Back button.

If your program will be run with JavaScript 1.0, you could put the following line in a SCRIPT tag early in your program. This emulates replace, which was introduced in JavaScript 1.1:

if (location.replace == null) location.replace = location.assign
The replace method does not create a new entry in the history list. To create an entry in the history list while loading a URL, use the History.go method.

Examples
The following example lets the user choose among several catalogs to display. The example displays two sets of radio buttons which let the user choose a season and a category, for example the Spring/Summer Clothing catalog or the Fall/Winter Home & Garden catalog. When the user clicks the Go button, the displayCatalog function executes the replace method, replacing the current URL with the URL appropriate for the catalog the user has chosen. After invoking displayCatalog, the user cannot navigate to the previous URL (the list of catalogs) by using browser's Back button.


Which catalog do you want to see?

Season
Spring/Summer
Fall/Winter

Category
Clothing
Linens
Home & Garden