Meta refresh is a method of instructing a web browser to automatically refresh the current web page or frame 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.
Use of meta refresh is discouraged by the World Wide Web Consortium (W3C), since unexpected refresh can disorient users. Meta refresh also impairs the web browser's "back" button in some browsers (including Internet Explorer 6 and before), although most modern browsers compensate for this (Internet Explorer 7 and higher, Mozilla Firefox, Opera, Chrome).
<head> to refresh page after 5 seconds:
<meta http-equiv="refresh" content="5">
http://example.com/ after 5 seconds:
<meta http-equiv="refresh" content="5; url=http://example.com/">
<meta http-equiv="refresh" content="0; url=http://example.com/">
Meta refresh tags have some drawbacks:
- If a page redirects too quickly (less than 2-3 seconds), using the "Back" button on the next page may cause some browsers to move back to the redirecting page, whereupon the redirect will occur again. This is bad for usability, as this may cause a reader to be "stuck" on the last website.
- A reader may or may not want to be redirected to a different page, which can lead to user dissatisfaction or raise concerns about security.
Meta refresh uses the
http-equiv meta tag to emulate the
Refresh HTTP header, and as such can also be sent as a header by an HTTP web server, although it should be noted that
Refresh is not part of the HTTP standard.
Alternatives exist for both uses of meta refresh.
An alternative is to send an HTTP redirection status code, such as HTTP 301 or 302. It is the preferred way to redirect a user agent to a different page. This can be achieved by a special rule in the Web server or by means of a simple script on the Web server.
onload property of the
<body onload="window.location = 'http://example.com/'"> <!-- Your content here --> </body>
To redirect noscript browsers
For example, if the current URL is
news.php, the browser redirects the user to
<noscript><meta http-equiv="refresh" content="0; url=news-nojs.php"></noscript>
This method has no alternatives, except making pages that work in noscript browsers.
- Core Techniques for Web Content Accessibility Guidelines 1.0 - W3C Note 6 November 2000
- Meta Refresh Tag, An About.com article covering the use of the tag for page reloading or redirection