Meta refresh: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Line 8: Line 8:
==Examples==
==Examples==
Refresh page after 5 seconds:
Refresh page after 5 seconds:
<source lang="html4strict"><meta http-equiv="refresh" content="5" /></source>
<source lang="html4strict"><meta http-equiv="refresh" content="5"></source>


Redirect to <code>wikipedia.org</code> after 5 seconds:
Redirect to <code>wikipedia.org</code> after 5 seconds:
<source lang="html4strict">
<source lang="html4strict">
<meta http-equiv="refresh" content="5;url=http://wikipedia.org" />
<meta http-equiv="refresh" content="5;url=http://wikipedia.org">
</source>
</source>


Redirect to <code>wikipedia.org</code> immediately:
Redirect to <code>wikipedia.org</code> immediately:
<source lang="html4strict">
<source lang="html4strict">
<meta http-equiv="refresh" content="0;url=http://wikipedia.org" />
<meta http-equiv="refresh" content="0;url=http://wikipedia.org">
</source>
</source>



Revision as of 16:17, 6 February 2008

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