js 倒计时跳转页面

时间:2022-12-18 22:07:24

<script type="text/javascript">
var i = 5;
var intervalid;
intervalid = setInterval("fun()", 1000);
function fun() {
if (i == 0) {
window.location.href = "<%=basePath%>home";
clearInterval(intervalid);
}
document.getElementById("mes").innerHTML = i;
i--;
}
</script>

<span id="littleTip">将在(<strong id="mes">5</strong>)秒钟后返回首页!</span></div>