$51.12

Is it possible to Redirect a Web Page in HTML?

Ask a question+
5

I set up a basic HTML page, and I want to redirect to another page. Is it possible? Please, help me to find a solution.

Sargsyan 415
add comment

5 Answers

4

You can use the meta tag to redirect from an HTML page. Also, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value in the content is the number of seconds; you want the page to redirect after.
For immediately loading you can set the content attribute to 0

<html>
   <head>
      <title>HTML Meta Tag</title>
      <meta http-equiv = "refresh" content = "2; url = https://www.tutorialspoint.com" />
   </head>
   <body>
      <p>Hello HTML5!</p>
   </body>
</html>

Try the examples yourself here

Muhamed Aziz 320
add comment
1

Preface

Yes. You can achieve it in 2 ways:

  1. Using meta tag with http-equiv and content attribute
  2. Using onload event attribute

Solution

1. Using meta tag with http-equiv and content attribute

You can simply inlcude the following meta tag in <head> of the HTML document:
<meta http-equiv="refresh" content="0; url=https://example.com/" />
Note that, you can change value 0 to what you like, which represents the delay in number of seconds.

2. Using onload event attribute

By simply adding onload HTML attribute to an existing or a new element. It does actually leverage some JavaScript though.
For example,

  1. Exisitng element, say, <body>
    <body onload="window.location.href = 'https://example.com';">
    ...
    </body>
    
  2. New element, say, <div>
    <div onload="window.location.href = 'https://example.com';">
    ...
    </div>
    

Hope it helps!

Sanmay Joshi 60
add comment
1

The simplest way to redirect to another URL is to use an HTML meta tag with the http-equiv parameter set to “refresh”. The content attribute sets the delay before the browser redirects the user to the new web page. For redirect to occur immediately, set this parameter to “0” seconds for the content attribute.

Example

<meta http-equiv="Refresh" content="0; url=https://www.w3docs.com" />

If you want your redirect to occur in an exact time, just define your preferred parameter (in seconds) for the content. Let’s consider an example set with 7 seconds redirect time set.

nandhini 55
add comment
1

Of course it is possible. You need to use HTML <a> tag. For more information go by the link How to Redirect a Web Page in HTML

Ani Manukyan 190
add comment
2

I suggest you to try the following

<meta http-equiv="refresh" content="0; url=http://example.com/" />

Also, please note, place it in the head section. Also, for older browsers ;

<p><a href="http://example.com/">Redirect</a></p>

will appear as Redirect, You will be allowed to go with an additional click.

Jack 590
add comment

Your Answer