Categories
Uncategorized

Creating an auto-forwarding web page

There are times when we want a web page to automatically redirect to another page. You may or may want to have a message displayed first.

In the first example here, the page will forward instantly, without displaying any message.

1
2
3
4
5
6
7
8
9
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta http-equiv="refresh" content="0;url=http://www.example.com">
    <title></title>
  </head>
<body>
</body>
</html>

In the second example, a message will be displayed with a delay before the next page automatically loads.

1
2
3
4
5
6
7
8
9
10
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta http-equiv="refresh" content="5;url=http://www.example.com">
    <title></title>
  </head>
<body>
<p>The following page will load in 5 minutes</p>
</body>
</html>

The key to all of this is in the content attribute on the fourth line of each example:
<meta http-equiv="refresh" content="5;url=http://www.example.com">

This attribute is in two parts, an integer followed by a URL. The integer is the number of seconds to pause, and should be set to zero if you don't want any pause at all.

If you do wish to pause before the page is forwarded, you should probably put a message in thesection as seen in the second example above.

To have a website or folder forward to another URL, just create an index.htm file with the appropriate code and place it in the website root or folder.

Leave a Reply