网页倒计时跳转JS代码
常用代码
网页倒计时跳转JS代码
2023-02-15 22:50
<span class="time"></span>
<script>
var t = 120; //60秒后跳转
var time = document.getElementsByClassName("time")[0];
function fun() {
t--;
time.innerHTML = t;
if(t <= 0) {
location.href = "跳转的网址";
clearInterval(inter);
}
}
var inter = setInterval("fun()", 1000);
</script>