Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  11] [ 6]  / answers: 1 / hits: 21668  / 14 Years ago, sat, january 1, 2011, 12:00:00

I have this code so far that redirects the user after 5 seconds to the correct URL:



<?php
$url = $_GET['url'];
header(refresh:5;url=$url);
include('ads.php');
?>



Please could you tell me how i could display a countdown timer saying Redirecting In.. with .. being the amount of seconds left. I am new to web development so all code will be helpful!


More From » php

 Answers
53
<script type=text/javascript>

(function () {
var timeLeft = 5,
cinterval;

var timeDec = function (){
timeLeft--;
document.getElementById('countdown').innerHTML = timeLeft;
if(timeLeft === 0){
clearInterval(cinterval);
}
};

cinterval = setInterval(timeDec, 1000);
})();

</script>

Redirecting in <span id=countdown>5</span>.


You can try this.


[#94417] Thursday, December 30, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dylondarrianb

Total Points: 48
Total Questions: 109
Total Answers: 104

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;