August 12, 2004

Automatic browser redirects

Ever been to a page that says, "We've moved! You'll be redirected in 20 seconds," and then 20 seconds later (or thereabouts) a new page appears without your having clicked anything? Here's how it's done.

At the top of your page, add a "meta" tag. This tag passes information about the page to the browser. for example, if I wanted to redirect you to this blog's home page after 30 seconds, I'd use the tag:

<META HTTP-EQUIV="refresh" content="30;URL=http://www.nicholaschase.com/blog">

Here's what that does. First it tells the browser to refresh, or reload the page. The content attribute tells it when -- in this case, after 30 seconds -- and where to go when it does. When the browser refreshes, it will go to the specified URL.

You can also use this for simply refreshing a page by adding its own URL. Just make sure you set the delay high enough for the page to be useable!

Technorati tags: HTML | meta | redirect | web development | web tips | web tricks |

src="http://feeds.feedburner.com/~s/ChaosMagnet?i=http://www.chaosmagnet.com/blog/archives/000467.html" type="text/javascript" charset="utf-8">
Posted by roadnick at August 12, 2004 12:03 AM | TrackBack

Comments

Post a comment









Remember personal info?