到目前为止,我有这段代码可以在 5 秒后将用户重定向到正确的 URL:
<?php
$url = $_GET['url'];
header("refresh:5;url=$url");
include('ads.php');
?>
请告诉我如何显示一个倒计时计时器,上面写着 Redirecting In..,其中 .. 是剩余的秒数。我是 Web 开发的新手,所以所有代码都会有所帮助!
最佳答案
<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>.
你可以试试这个。
关于php - 显示重定向 In.. CountDown Timer PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4575789/