HTML Tutorial - Refreshing and Redirecting
This tutorial will show you how to refresh a web page using the < meta > tag.
The Attributes
The meta tag has many possible attributes, but for the purpose of this tutorial we only need to use 2, the http-equiv attribute, which tells the browser what you are going to describe, in our case it will be refresh. The other attribute that we are using is the content attribute - which, when you have set the http-equiv attribute to refresh, tells the browser how many seconds to delay the refresh by, and what url to refresh to (in case you wish to redirect to another page, and not just refresh the current page). Here is what is looks like:
< meta http-equiv= 'refresh' content= '3;url=http://www.infinite-fire.net/index.php' >
Now as you can see, this would refresh the browser to http://www.infinite-fire.net - nice eh, if you wish to increase or decrease the delay time, just lower or raise the 3 - which is measured in seconds, if you want the page to refresh with no delay, set this to 0.
Redirection
If you wish to redirect your users to a new page, simply change the url part of the tag - for example if I wished to redirect to google.com, I would use this:
< meta http-equiv= 'refresh' content= '3;url=http://www.google.com' >
Extra - for PHP users
A nice trick when using PHP is to refresh the current page using a superglobal variable, so that you can replicate the tag on many pages, without having to manually insert the page name, here is what I mean:
< meta http-equiv= 'refresh' content= '3;url= ' >
This easy little trick uses the superglobal array $_SERVER, which contains lots of details about the server (around about 35-40 different settings, such as the ip address - $ _SERVER[’HTTP_HOST’], the port being used - $ _SERVER[’SERVER_PORT’] and many, many more - to see them all make a PHP page with the phpinfo() function, and they are all listed (along with their values) towards the bottom of the page), to get the current page name, then echo it into the url property.
Conclusion
You can now refresh your page, or refresh to another page (redirect) and, if using PHP, can refresh the current page without manually entering the page name.