In Topic 75, you saw how to use a meta tag to set an automatic refresh cycle. The syntax of the meta tag looked like this: <meta http-equiv="refresh" content="x,#">
where x represents the number of seconds before the browser refreshes the page, and # is browser shorthand for the current document. Just as you're free to change the value of x, you're free to change the Web page that the browser reloads. Simply supply a different URL in place of the number sign. In effect, this trick creates a page that automatically redirects the browser to a new location after a specified number of seconds. These kinds of pages are handy to have. Say you just redesigned and reorganized your site, and some old nav categories no longer exist in the new, improved version. But visitors to your site might have bookmarks to the old pages. Instead of frustrating your audience when they try to load a nonex istent document, pop a replacement page like the kind in Figure 76.1 to the location of your old, obsolete page. Very classy. Listing 76.1. View Source for Figure 76.1.[View full width] <html> <head> <title>Uh, oh!</title> <meta http-equiv="refresh" content="5, http://newpage.htm"> </head> <body> <h1>Uh, oh!</h1> <p>The page you're looking for no longer exists. Your browser will automatically jump to the new page in five seconds. Please update your bookmarks.</p> </body> </html> Figure 76.1. Use a page like this to redirect your visitors to a new location.The meta tag in the View Source for Figure 76.1 works just like the one at the beginning of this topic. The 5 in the content attribute indicates a five-second pause, and the URL tells the browser where to jump after the five seconds.
Five seconds is probably way too long a wait for most of your visitors. Still, you want to give the few who actually read your content a fair chance to see what the page says before the browser jumps away, in which case five seconds is probably way too short. How do you satisfy both types of Web surfers? Easy. Crank up the redirect delay to about ten to fifteen seconds, and include a direct link to the new page, as in Figure 76.2. Listing 76.2. View Source for Figure 76.2.[View full width] <html> <head> <title>Uh, oh!</title> <meta http-equiv="refresh" content="10, http://newpage.htm"> </head> <body> <h1>Uh, oh!</h1> <p>The page you're looking for no longer exists. Your browser will automatically jump to the <a href="http://newpage.htm">new page</a> in ten seconds. Please update your bookmarks.</p> </body> </html> Figure 76.2. To make the redirect go faster for impatient visitors, include a direct link to the correct page.
|