All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

HTML Redirect To Another Page On Load

Last Updated : Mar 11, 2024

HTML Redirect To Another Page On Load

In this tutorial we will show you the solution of HTML redirect to another page on load, many times we see that when we click on a link and want to open a particular webpage of website by typing it, browser redirects us to its home page or another parent page.

So, in this article we will understand how to redirect to another page in html on load.

Step By Step Guide On HTML Redirect To Another Page On Load :-

As, here are many ways with help of which we can redirect to another page on load. Let us understand them one by one with the codes given below.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>html redirect to another page on load </title>
<meta http-equiv="refresh" content="0; url=http://demo.com/" />
</head>
<body>
<script>
 window.location.href = "http://www.talkercode.com";
</script>
</body>
</html>
  1. First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
  2. Secondly, the <html> tag is used to indicate the beginning of an HTML document.
  3. As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
  4. Here, then we create a body tag. All the content which we want to show on browser’s screen or display is always written inside this codes.
  5. As, here in body we use script tag. And inside script tag as we see that we use a method named as window.location.href here. We are able to use this method with JavaScript and with jQuery also. This method is use to get the URL of the current page. But if we put value in this then we also can change the value of URL also.
  6. One thing more here as you see in the head tag. We use meta tag there, and this tag also used to redirects to another webpage on load. This tag is always used inside the head tag of current webpage.
  7. And inside content attribute we have to give value using URL. As you can see that inside URL we give the value like https://demo.com you are able to give the value of that page where we want our webpage to redirect.
  8. Mostly as you see our further languages that are used with html. There are many inbuilt functions and methods that are used in that language to redirect html page to another page. We hope that you understand these steps easily.
  9. At last, the <body> and <html> tags are closed with </body> and </html> respectively.

Conclusion :-

At last in conclusion, here we can say that with the help of this article we are able to understand how to redirect to another page on load using html.

I hope this tutorial on HTML redirect to another page on load helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Dikshita

Passionate Electronics and Communication Engineering student with expertise in web development (HTML, CSS, JS,PHP, Bootstrap, React.js) and content writing. Eager problem solver and tech enthusiast, adept at creating engaging web experiences.

Follow Dikshita On Linkedin 🡪