How to redirect one HTML page to another on load?

 

You can redirect one HTML page to another using the <meta> tag with the http-equiv attribute set to "refresh" and the content attribute containing the delay time and the target URL. Here's an example:

html
<!DOCTYPE html> <html> <head> <meta http-equiv="refresh" content="5;url=destination.html"> </head> <body> <p>This page will redirect to another page in 5 seconds...</p> </body> </html>

In this example:

  • The <meta> tag with the http-equiv attribute set to "refresh" triggers a page refresh or redirection.
  • The content attribute specifies the delay time in seconds (in this case, 5 seconds) and the URL of the destination page.
  • After the specified delay, the browser will automatically navigate to the URL provided in the url attribute.

This approach is a simple way to perform a redirection after a certain amount of time. Keep in mind that this method might not be suitable for all scenarios, as it's not as flexible as using JavaScript or server-side redirects.

Comments