Sams Teach Yourself HTML 4 in 24 Hours

Sams Teach Yourself HTML 4 in 24 Hours

By Dick Oliver

Loading Another Page Automatically

When you are managing a Web site, it may become necessary to move some pages from one address to another. You might decide, for example, to change the service provider or your whole site's domain name. You might just reorganize things and move some pages into a different directory folder.

What happens, then, when someone visits his or her favorite Web page on your site after you've moved it? If you don't want your visitor to be stranded with a Not Found error message, you should put a page at the old address that says, "This page has moved to&hellip" with the new address (and a link to it).

Chances are, you've encountered similar messages on the Internet yourself. Some of them probably employed the neat trick you're about to learn; they automatically transferred you to the new address after a few seconds, even if you didn't click a link.

In fact, you can make any page automatically load any other page after an amount of time you choose. The secret to this trick is the <meta /> tag, which goes in the <head> section of a page and looks like the following:

<meta http-equiv="refresh" content="5; nextpage.htm" />

Replace 5 with the number of seconds to wait before loading the next page and replace nextpage.htm with the address of the next page to load.

For example, the page listed in Figure 23.5 looks like Figure 23.6 when viewed in a Web browser. After 5 seconds (during which a GIF animation counts down from 5 to 0), the <meta /> tag causes the page at http://netletter.com/nicholas/ (Figures 23.7 and 23.8) to appear.

23fig05.gif

Figure 23.5 The <meta /> tag causes the Web browser to automatically load the page shown in Figure 23.7 after five seconds.

23fig06.gif

Figure 23.6 This is the page listed in Figure 23.5. I used a GIF animation (countdn.gif) to entertain readers while they're waiting for the next page.

23fig07.gif

Figure 23.7 The <base /> tag in this page has nothing to do with page forwarding. (<base /> is discussed in the next section of this hour.)

23fig08.jpg

Figure 23.8 This is the page listed in Figure 23.7. The page in Figures 23.5 and 23.6 forwards to this page automatically after the five-second delay.

Share ThisShare This

Informit Network