Free HTML Tutorials   •   CSS   •   Popups tutorial   •   Frames Tutorials   •   Forms Tutorials   •   Beginners HTML Tutorials   • Advanced HTML Tutorials   • JavaScripts   • Free Web Page Tutorials   •   Free Downloads
OzWebLogo Intermediate Section

AUTOMATIC REDIRECTION
 
 

META REFRESH

Here is a neat bit of code to use if your web address has changed, or you need to redirect your visitors automatically. It is called " META REFRESH" and can be used to send them to the page of your choice. Be careful when using this, though, especially on your index or main page. Some search engines are trained to look for a meta refresh that leads from a page stuffed with keywords to the real page, redirecting the user so quickly that they never see the keyword-loaded page. Thus, if you refresh too quickly (in some cases anything less than 8 seconds is too quickly) you stand the chance of having the page pulled from the listings. Of course, if it isn't your main page, you probably won't need to worry about that.

So, how is it done? Well, here is the code that will do it:

    <HTML>
    <HEAD>
    <META HTTP-EQUIV="refresh" content="8;URL=http://www.yoursite.com/newpage.html">
    <TITLE>This page has moved </TITLE>
    </HEAD>
    <BODY>
    Please update your bookmarks
    </BODY>
    </HTML>

Notice that the refresh tag comes before your title tag. The content=" " command does two things. It tells the browser how many seconds to wait before executing the refresh, and then what URL it should be redirected to. Be careful when you write this.

NOTE: the quote marks are around the entire content =" " command, not around the number of seconds or the URL individually. They are separated by a single semicolon (;).

Of course, you can write whatever you like in your BODY section. Keep it short enough for people to read it in the time you have allowed for the refresh to work. Also, to cater for users with older browsers, you should add a manual link to the new page inside the body section of your page:

    <HTM>
    <HEAD>
    <META HTTP-EQUIV="refresh" content="8;URL=http://www.yoursite.com/newpage.html">
    <TITLE>This page has moved</TITLE>
    </HEAD>
    <BODY>
    This page has moved. If your browser does not automatically redirect you in a few seconds, click
    <A HREF="http://www.yoursite.com/newpage.htm"> HERE</A> to go to the new page.
    </BODY>
    </HTML>


As usual I will give you an example. Click the link below to see the page. You will be returned to this page after about eight seconds. If not, click as indicated.

     Meta Refresh Example Page

If this doesn't work, it is probably time to update your browser. I don't know if it works in browsers other than Netscape and IE, so some feedback would be helpful.



Next:  Summary & Practice 2

Intermediate Index

Help
Copyright ©1998-2008 OzWebWeaver.