首页 > 代码库 > js 倒计时跳转页面

js 倒计时跳转页面

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

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

js 倒计时跳转页面