Auto Page Refresh and URL redirect with Meta Refresh Tag
Meta Refresh is a method for automatically reloading the web page
or redirecting to another location after pre-defined time interval. Meta refresh
tag instructs the web browser to change or reload the current URL after the defined
time interval. If URL is defined with content parameter, the web browser
redirects to the new web page. For url redirect, you may set the
time interval either to zero or a very low value. Meta refresh tag is placed in
head section of html document.
How to Refresh the Page with HTML meta tag
The html code for refreshing the content is really simple. You need to place the
following code in between <head> tags of your html file.
<meta http-equiv="refresh" content="5">
You are setting here the http-equiv parameter to refresh and content
parameter to time interval in seconds.
The meta refresh is commonly used to reload the web pages with dynamic contents
such as match scores, news, stock ticker, weather, etc.
Auto forwarding to new URL
The html code for redirecting to a new page is similar to page refresh. But in this case, you
need to also define the URL of the new page to be reloaded. Here is the html code
<meta http-equiv="refresh" content="5;URL='http://new-page.com/'">
Just remember that you need to specify the URL after putting a semi-colon (;) after
time interval in seconds. If you want to immediately redirect, put the time interval
<meta http-equiv="refresh" content="0;URL='http://new-page.com/'">
While the meta refresh has traditionally been used for refreshing the content or
redirecting to other web page conveniently, there are many new techniques available
now. The use of meta refresh tag is now discouraged by W3C due to the following
- The time for user to read the page cannot be predicted. Premature refresh can disorient
- Users do not have control to stop automatic refresh or redirect.
- The markup for URL redirect is non-standard.
- It can disrupt the browser's history of visited pages.
- In case of URL redirect with zero or very low time interval, "Back" button will
not work in many browsers.
Apart from above, meta refresh is also not recommended from search engine optimization
point of view. Many of the spammers use html meta refresh tag to fool the search
engines. As such, search engines tend to either penalize or ban these websites.
Alternatives to Meta Refresh Tag
- Most of the leading websites today use AJAX to reload only the dynamic content in
the web pages. This is very user friendly and takes comparatively little resources also.
- You may provide with a button or link to the same page at the top, so that the user
may click when he/she wants to refresh the contents.
- Use HTTP 301 redirect method for URL redirect. This is an SEO friendly method for page redirect.