Meta refresh

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Twsx (talk | contribs) at 11:18, 8 April 2008 (Undid revision 204162052 by 67.233.190.112 (talk) - this space character is redundant.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Meta refresh is a method of instructing a web browser to automatically refresh the current web page after a given time interval, using an HTML meta element with the http-equiv parameter set to "refresh" and a content parameter giving the time interval in seconds. It is also possible to instruct the browser to fetch a different URL when the page is refreshed, by including the alternative URL in the content parameter. By setting the refresh time interval to zero (or a very low value), this allows meta refresh to be used as a method of URL redirection.

Using meta refresh for redirection is considered by the W3C to be a poor practice, since it does not communicate any information about either the original or new resource to the browser (or search engine). Many web design tutorials also point out that client side redirecting tends to interfere with the normal functioning of a web browser's "back" button. After being redirected, clicking the back button will cause the user to go back to the redirect page, which redirects them again. Some modern browsers seem to overcome this problem however, including Safari, Mozilla Firefox and Opera. Others, like IE, can be "tricked" by doing two rapid clicks of the "back" button - the first lands you on the redirect page, and before the time interval expires the second click takes effect to land you on the previous page. The use of zero delay redirects may cause the two rapid clicks technique to be impossible. A minimum delay of 1 second should be used for all redirects.

The W3C's Web Content Accessibility Guidelines (7.4) discourage the creation of auto-refreshing pages, since most web browsers do not allow the user to disable or control the refresh rate.

Examples

Refresh page after 5 seconds:

<meta http-equiv="refresh" content="5"/>

Redirect to wikipedia.org after 5 seconds:

<meta http-equiv="refresh" content="5;url=http://wikipedia.org"/>

Redirect to wikipedia.org immediately:

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

References