How to automatically transfer visitors to a new web page ?

This article is all about how can we transfer our web page visitors to another web page. This may be required in cases when need to do a temporary change in our website or we have permanently shifted our website to a new website. We can use this method to automatically redirect our users or tell search engines by redirecting them to the new site.

Approach: There are so many methods in HTML to do this but we are going to talk about meta tags. It is the simplest and easiest way to automatically transfer your web page to any URL.

Syntax:

<meta
     http-equiv="refresh"
     content="0;
     url='https://www.w3wiki.net/'"
/>

Parameters: The<meta> tag needs three attributes for redirecting the user to another page as shown below:

  • http-equiv: This is used for instructing a web browser to automatically refresh the current web page.
  • content: This is used to specify how much delay you want to redirect to a new page.
  • url: This is used to tell in which web page we have to forward our old website.

The below examples will demonstrate the use of the <meta> tag to redirect the pages.

Example 1: This code will redirect our web page to the w3wiki website after 2 seconds.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <!-- Added meta tag-->
    <meta http-equiv="refresh" 
          content="2; 
          url='https://www.w3wiki.net/'" />
</head>
  
<body>
    <h1>Welcome To GFG</h1>
    <h2>This Page will redirect to
        w3wiki.net in 2 seconds
    </h2>
</body>
  
</html>


Output:

Example 2: This code will redirect our web page to Google after 2 seconds.

HTML




<!DOCTYPE html>
<html>
  
<head>
  
    <!-- Added meta tag-->
    <meta http-equiv="refresh" content="5; 
      url='http://google.com/'" />
  
</head>
  
<body>
    <h1>Welcome To GFG</h1>
    <h1>This Page will redirect to
    Google in 5 seconds</h1>
</body>
  
</html>


Output:



Contact Us