Ron F wrote:Hi Ninja's,
I was looking for a really basic script that will cause a page to redirect to another page. However this needs to happen after a countdown.
I don't know if you have seen those websites that say something along the these lines:
Example:
"you will be redirected in "5" seconds...
If you are not redirected click Here"
does anyone know or have a javascript handy?
Hey Ron,
funny you should ask, I do happen to have one handy, probably not the best script in the world and anyho:
HTML:<h2>You will be redirected in:</h2><h2><span id="mytimer"></span></h2><br/>
If you are not redirected then click <a href="http://www.theitninja.co.uk">here</a>
Javascript Count down Redirect: function Redirect(time, url, countdown){
var c = document.getElementById(countdown);
time = time -1;
if(c!=null){c.innerHTML = time;}
if(time == 0){
window.location = url;
}
setTimeout("Redirect("+(time)+",'"+url+"','"+countdown+"')", 1000);
}
then you can simply call this on page load (remember to start of 1 second higher):
Redirect(6, "http://www.theitninja.co.uk", "mytimer");
give that a shot