Meta refresh: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Tags: Mobile edit Mobile web edit
No edit summary
Tag: references removed
Line 1: Line 1:
{{ref improve|date=June 2014}}--though most modern browsers compensate for this ([[Internet Explorer 7]] and higher, [[Mozilla]] [[Firefox]], [[Opera (web browser)|Opera]], [[Google Chrome]]).
{{ref improve|date=June 2014}}
{{HTML}}
'''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|<code>meta</code> element]] with the <code>http-equiv</code> parameter set to "<code>refresh</code>" and a <code>content</code> parameter giving the time interval in seconds. It is also possible to instruct the browser to fetch a different [[Uniform Resource Locator|URL]] when the page is refreshed, by including the alternative URL in the <code>content</code> parameter. By setting the refresh time interval to zero (or a very low value), meta refresh can be used as a method of [[URL redirection]].

==History==
This feature was originally introduced by [[Netscape Navigator]] 1.1 (circa 1995), in a form of HTTP header and corresponding HTML <code>meta</code> HTTP-equivalent element, which allows document author to signal client to automatically reload the document or change to a specified URL after a specified timeout.<ref name="netscape1.1-pushpull">{{cite web|url=http://home.netscape.com/assist/net_sites/pushpull.html|title=An Exploration of Dynamic Documents|publisher=Netscape Communications Corporation|archive-url=https://web.archive.org/web/20020124130844/http://home.netscape.com/assist/net_sites/pushpull.html|archive-date=2002-01-24|access-date=2020-04-24}}</ref> It is the earliest [[Polling (computer science)|polling]] mechanism available for [[World wide web|the web]]{{citation needed|date=April 2020}}, to let user see the latest update in a frequently-changing webpage, such as ones displaying [[Share price|stock price]] or [[Weather forecasting|weather forecast]].

While this feature has not ever been standardized, it is supported by default in almost all later web browsers.{{citation needed|date=April 2020}}

==Usability==
Use of meta refresh is discouraged by the [[World Wide Web Consortium]] (W3C), since unexpected refresh can disorient users.<ref>[https://www.w3.org/TR/WCAG10-CORE-TECHS/#auto-page-refresh Core Techniques for Web Content Accessibility Guidelines 1.0] - W3C Note 6 November 2000</ref> 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 (web browser)|Opera]], [[Google Chrome]]).


There are legitimate uses of meta-refresh, such as providing updates to dynamic web pages or implementing site controlled navigation of a website without [[JavaScript]]. Many large websites use it to refresh news or status updates, especially when dependencies on JavaScript and redirect headers are unwanted.
There are legitimate uses of meta-refresh, such as providing updates to dynamic web pages or implementing site controlled navigation of a website without [[JavaScript]]. Many large websites use it to refresh news or status updates, especially when dependencies on JavaScript and redirect headers are unwanted.

Revision as of 00:15, 15 July 2020

--though most modern browsers compensate for this (Internet Explorer 7 and higher, Mozilla Firefox, Opera, Google Chrome).

There are legitimate uses of meta-refresh, such as providing updates to dynamic web pages or implementing site controlled navigation of a website without JavaScript. Many large websites use it to refresh news or status updates, especially when dependencies on JavaScript and redirect headers are unwanted.

Examples

Place inside <head> to refresh page after 5 seconds:

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

Redirect to http://example.com/ after 5 seconds:

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

Redirect to http://example.com/ immediately:

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

Drawbacks

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.[1]

Alternatives

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 Refresh is not part of the HTTP standard.

Alternatives exist for both uses of meta refresh.

For redirection

An alternative is to send an Https redirection 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.

JavaScript is another alternative, but not recommended, because users might have disabled JavaScript in their browsers.

The simplest way of JavaScript redirect using the onload property of the body tag:

<body onload="window.location = 'ht

<https.google.com --

=== For refresh ===
An alternative method is to provide an interaction device, such as a button, to let the user choose when to refresh the content. Another option is using a technique such as [[Ajax (programming)|Ajax]] to update (parts of) the Web site without the need for a complete page refresh, but this would also require that the user enable JavaScript in their browser.

=== To redirect noscript browsers ===
Using the following technique, browsers that do not understand JavaScript can be redirected to alternative pages which are designed without requiring support for JavaScript. 

For example, if the current URL is <code>news.[[HTML|html]]</code>, the browser redirects to <code>news-nojs.html</code>.
<syntaxhighlight lang="html4strict"><noscript><meta http-equiv="refresh" content="0; url=news-nojs.html"></noscript>

References

  1. ^ Meta Refresh Tag, An About.com article covering the use of the tag for page reloading or redirection

External links