How can I automatically redirect the user to another page?

Sometimes you need to redirect the user from one page to another. For example when a page has moved. You can do this automatically with the META element, using http-equiv="refresh". You must put this element in the HEAD of the page.

This tells the client it must refresh the page after a number of seconds. The number of seconds and the URL of the new page must be present in the CONTENT attribute :

Source
<META http-equiv="refresh" content="10; url=New-page.html">

Important note: make sure the URL you give is fully qualified (e.g. http://whatever/whatever). That is, don't use a relative URL.

The interval can be 0 seconds. This will cause the browser to load the data from the supplied URL as soon as it can. This makes it possible to use it as an immediate redirection.

It's best to provide a small text in the BODY of the page, and include a link to the page for browsers that don't support automatic redirection.

Back to the FAQ main page
Statistics

  Copyright © 1996 - 2000 Rob Schlüter,   schluter@knoware.nl   (last updated 1999/03/01)