English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
replace()method replaces the current resource with the resource provided in the URL.
WithAssign()The difference between the two methods is that after using replace(), the current page will not be saved in the session history, which means that users will not be able to navigate to the page using the back button.
If you want to load a new document, please useassign()Method, and use options to navigate back to the original document.
location.replace(URL)
location.replace("https://www.oldtoolbag.com");Test See‹/›
All browsers fully support the replace() method:
Method | |||||
replace() | Yes | Yes | Yes | Yes | Yes |
Parameter | Description |
---|---|
URL | A string containing the URL of the page to be viewed |
Return Value: | None |
---|
Location Reference:location.assign() method
Location Reference:location.reload() method