The ES6 page redirect is used to send a request to different website addresses to the user and browser search engine, (search engine and user received different website address to that was requested by the search engine or the user). Redirecting to a different page that was not requested by the user or by search engine can be on the same server or maybe on a different server. Also, it can be a different website.
- location.replace() Method: This method will replace the current website location to the redirected website location by using the .replace() method.
window.location.replace = "Your redirected link"
- location.assign() Method: This method will assign a new location to the redirected website location by using the .assign() method.
window.location.assign = "Your redirected link"
- location.reload() Method: This method will reload the current document by using the .reload() method.
window.location.reload = "Your redirected link"
- window.navigate() Method: This method can be used in Internet Explorer only all the other browsers remove this method. So it is good to be avoided because other browsers will not support this method. This method is similar to the .location.assign() method. This method assigns a new value that will be navigated by using the .navigate() method.
window.navigate = "Your redirected link"
Below example will illustrates the whole concept of Page redirecting:
- Before clicking the button:
- After clicking the button:
Note: Add the rel = “canonical” inside the head section of the web page to inform the search engine when you are using the page redirecting method.
<link rel = "canonical" href = "Redirecting Page" />
- How to redirect a page to another page in HTML ?
- How to use Meta Tag to redirect an HTML page?
- How to redirect to a particular section of a page using HTML or jQuery?
- ES6 | Page Printing
- How to display search result of another page on same page using ajax in JSP?
- How to show Page Loading div until the page has finished loading?
- How to pass form variables from one page to other page in PHP ?
- How to make a redirect in PHP?
- How to redirect to another webpage in HTML?
- Post/Redirect/Get (PRG) Design Pattern
- Express.js res.redirect() Function
- ASP Redirect Method
- How to force redirect to a particular route in angular?
- ES6 | RegEx
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.