views:

195

answers:

6
+1  Q: 

Delayed jump

How do I cause the page to make the user jump to a new web page after X seconds. If possible I'd like to use HTML but a niggly feeling tells me it'll have to be Javascript.

So far I have the following but it has no time delay

<body onload="document.location='newPage.html'">
+13  A: 

A meta refresh is ugly but will work. The following will go to the new url after 5 seconds:

<meta http-equiv="refresh" content="5;url=http://example.com/"/&gt;

http://en.wikipedia.org/wiki/Meta_refresh

slashnick
This really is the best - no JavaScript needed, so it will work just about anywhere.
Jason Bunting
+1  A: 

Put this is in the head:

<meta http-equiv="refresh" content="5;url=newPage.html">

This will redirect after 5 seconds. Make 0 to redirect onload.

hubbardr
+1  A: 

You can use good ole' META REFRESH, no JS required, although those are (I think) deprecated.

Adam Bellaire
+3  A: 

If you are going the JS route just use

setTimeout("window.location.href = 'newPage.html';", 5000);
Jason Z
+1  A: 

The Meta Refresh is the way to go, but here is the JavaScript solution:

<body onload="setTimeout('window.location = \'newpage.html\'', 5000)">

More details can be found here.

Huuuze
A: 

The JavaScript method, without invoking eval in the the setTimeout:

<body onload="setTimeout(function(){window.location.href='newpage.html'}, 5000)">
Andrew Hedges