Reputation: 110969
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'">
Upvotes: 2
Views: 1435
Reputation: 21796
The JavaScript method, without invoking eval
in the the setTimeout
:
<body onload="setTimeout(function(){window.location.href='newpage.html'}, 5000)">
Upvotes: 0
Reputation: 16357
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.
Upvotes: 1
Reputation: 13422
If you are going the JS route just use
setTimeout("window.location.href = 'newPage.html';", 5000);
Upvotes: 4
Reputation: 110429
You can use good ole' META REFRESH, no JS required, although those are (I think) deprecated.
Upvotes: 1
Reputation: 3173
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.
Upvotes: 1
Reputation: 26539
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/"/>
http://en.wikipedia.org/wiki/Meta_refresh
Upvotes: 15