XHanch Studio Log in | Register | Cart

Forum

[How to] Automatica...
 
Notifications
Clear all

[How to] Automatically refresh/reload/redirect page with meta refresh tag

1 Posts
1 Users
0 Likes
1,424 Views
XHanch
(@xhanch-alt)
Posts: 2105
Member Admin
Topic starter
 

The meta refresh tag or meta redirect is a tool for reloading and redirecting web pages. Remember that the meta refresh tag is easy to use and easy to use poorly.

The meta tag belongs within the <head> of your HTML document.

When used to refresh the current page, the syntax looks like this:

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

Code breakdown:

  • <meta> - This is the HTML tag. It belongs in the <head> of your HTML document. You can learn more about the meta tag in the HTML tag library.
  • http-equiv="refresh" - This attribute tells the browser that this meta tag is sending an HTTP command rather than a standard meta tag. Refresh is an actual HTTP header used by the web server. It tells the server that the page is going to be reloaded or sent somewhere else.
  • content="600" - This is the amount of time, in seconds, until the browser should reload the current page.

One of the most common uses of the reload version of the refresh tag is to reload a page that has dynamic content on it. For example: a stock ticker or weather map. Some people also use them to reload ads, but that can annoy your readers.

While being able to reload the current page is useful, it is not typically what people want from the meta refresh tag. To redirect to a new page, the syntax is nearly the same:

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

The only difference is in the content attribute. content="2;url= http://xhanch.com" - The number is the time, in seconds, until the page should be redirected. Then, separated by a semi-colon (;) you write the URL to the page to be loaded.

Meta refresh tags have some drawbacks:

  • Meta refresh redirects have been used by spammers to fool search engines. So search engines remove those sites from their database. If you use a lot of meta refresh tags to redirect pages, the search engines may decide your site is spam and delete it from their index. It’s better to use a 301 Server Redirect instead.
  • If the redirect happens quickly (less than 2-3 seconds), readers with older browsers can’t hit the “Back” button. This is a usability problem.
  • If the redirect happens quickly and goes to a non-existant page, your readers won’t be able to hit the “Back” button. This is a usability problem that will cause people to completely leave your site.
  • Refreshing the current page can confuse people. If they didn’t request the reload, some people can get concerned about security.
 
Posted : 30/04/2011 7:02 pm
Share:

× Close Menu