Location: replace() method - Web APIs | MDN
Syntax
Parameters
url-
A string or any other object with a stringifier, such as a
URLobject, containing the URL of the page to navigate to.
Exceptions
SecurityErrorDOMException-
Browsers throttle navigations and may throw this error, generate a warning, or ignore the call if it's called too frequently.
SyntaxErrorDOMException-
Thrown if the provided
urlparameter is not a valid URL.
Return value
None (undefined).
Examples
js
// 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
| Specification |
|---|
| HTML # dom-location-replace-dev |
Browser compatibility
See also
- The
Locationinterface it belongs to. - Similar methods:
Location.assign()andLocation.reload().