Difference between window.location.replace(...)
and window.location.href
There are several time when we get confused on multiple way for performing one action.
Simple example is redirecting/navigating to other page.
- use function called window.location.replace()
- use properties called location.href
window.location.replace()
This function will not save the current page in session history, so when you click on the back button, It will not have previous page url. It is more useful when you are looking for redirection instead of navigation
window.location.replace(‘https://www.lucentinnovation.com');
window.location.href
This attribute will save the current page in session history, so when you click on the back button, It will pop previous page url. It is more useful when you are looking for navigations.
window.location.href= ‘https://www.lucentinnovation.com';