// The behavior of this method would be as HTTP redirect window.location.replace("https://itsmycode.com"); // The behavior of this would be as clicking on a link window.location.href = "http://code.askemin.com"; //Navigate to the Location.reload article window.location.assign("https://itsmycode.com");
All the three code does the same job. It would redirect to the URL, however, the Location.replace() method replaces the current resource with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session History, meaning the user won’t be able to use the back button to navigate to it.
Redirect Page using Jquery
There are multiple ways of redirecting to a page in Jquery. Let us take a look of each one.
Example using Jquery:
$(location).attr('href','https://itsmycode.com/'); $(window).attr('location','https://itsmycode.com') $(location).prop('href', 'https://itsmycode.com')
If you are using Jquery to redirect to a page then you could use one of the above code for redirection.