Baseline Widely available
The replace()
method of the Location
interface replaces the current resource with the one at the provided URL. The difference from the assign()
method is that after using replace()
the current page will not be saved in session History
, meaning the user won't be able to use the back button to navigate to it. Not to be confused with the String
method String.prototype.replace()
.
url
A string or any other object with a stringifier, such as a URL
object, containing the URL of the page to navigate to.
SecurityError
DOMException
Browsers throttle navigations and may throw this error, generate a warning, or ignore the call if it's called too frequently.
SyntaxError
DOMException
Thrown if the provided url
parameter is not a valid URL.
None (undefined
).
// Navigate to the Location.reload article by replacing this page
window.location.replace(
"https://developer.mozilla.org/en-US/docs/Web/API/Location.reload",
);
Specifications Browser compatibility See also
Location
interface it belongs to.Location.assign()
and Location.reload()
.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4