It is often required to redirect to another webpage on loading a webpage, for example, due to the contents being moved to the new webpage.
Demonstrated here are two simple methods to redirect to another webpage on load.
Method-1: Using http-equiv attribute of the meta tag in HTML.
<meta http-equiv="refresh" content="seconds; url=URL">
After 2 seconds:
Note: In some older browsers, like Internet Explorer 6, refresh may cause unexpected results and impair the browser’s Back button. This is compensated for in most modern browsers (Internet Explorer 7 and higher, Google Chrome, Mozilla Firefox, Microsoft Edge).
window.location.href = "URL"
- 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 Redirect
- Post/Redirect/Get (PRG) Design Pattern
- Express.js res.redirect() Function
- ASP Redirect Method
- How to force redirect to a particular route in angular?
- Reading selected webpage content using Python Web Scraping
- How To Add Google Translate Button On Your Webpage?
- How to Add Google Charts on a Webpage?
- Reader's View of a GeeksforGeeks webpage
- How to connect multiple MySQL databases on a single webpage ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.