Open In App

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.geeksforgeeks.org/'"
/>

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



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 GeeksforGeeks website after 2 seconds.




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

Output:

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




<!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:


Article Tags :