files/en-us/web/api/location/replace/index.md
{{ APIRef("HTML DOM") }}
The replace() method of the {{DOMXref("Location")}}
interface replaces the current resource with the one at the provided URL. The difference
from the {{domxref("Location.assign","assign()")}} method is that after using
replace() the current page will not be saved in session {{domxref("History")}},
meaning the user won't be able to use the back button to navigate to it.
Not to be confused with the {{jsxref("String")}} method {{jsxref("String.prototype.replace()")}}.
replace(url)
url
SecurityError {{domxref("DOMException")}}
SyntaxError {{domxref("DOMException")}}
url parameter is not a valid URL.None ({{jsxref("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}}
{{Compat}}