I have seen many methods like window.location.href=url
, window.location.replace(...)
and window.location
, but can anyone tell me which is the best method to redirect user from one webpage to another using jQuery or javascript?
thank you
window.location.replace(
url)
is better than using window.location.href
.replace()
does not keep the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco, as it simulates an HTTP redirect
while windows.location.
href provides similar behavior as clicking on a link.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly