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 use Meta Tag to redirect an HTML page?
- How to redirect a page to another page in HTML ?
- ES6 | Page Redirect
- How to Add Google Charts on a Webpage?
- How To Add Google Translate Button On Your Webpage?
- Reader's View of a GeeksforGeeks webpage
- How to connect multiple MySQL databases on a single webpage ?
- Reading selected webpage content using Python Web Scraping
- HTML Course | Structure of an HTML Document
- HTML Course | Basics of HTML
- HTML | DOM HTML Object
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.