Monday, November 7, 2011

JavaScript: waiting 5 seconds and auto redirects

<div>Redirect to the home page in <span id="countdown">5</span> secondes...</div>
<script type="text/javascript">
function countDown(){
 var count = document.getElementById('countdown').innerHTML-1;
 document.getElementById('countdown').innerHTML = count;
 if (count<=0) {
  location.href = "http://networkplot.tk";
 }
 else {
  t=setTimeout("countDown()",1000);
 }
}
countDown();
</script>

1 comment: