Name
Location.replace( ): replace one displayed document with another â JavaScript 1.1
Synopsis
location
.replace(url
)
Arguments
-
url
A string that specifies the URL of the new document that is to replace the current one.
Description
The replace( )
method of
the Location object loads and displays a new document. Loading a
document in this way is different from simply setting
location
or
location
.href
in one important respect: the
replace( )
method does not
generate a new entry in the History object. When you use replace( )
, the new URL overwrites the
current entry in the History object. After calling replace( )
, the browserâs Back button does not return you to the
previous URL; it returns you to the URL before that one.
See Also
History
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.