JS实现页面倒计时跳转到指定页面

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
window.onload = function(){
var time = 5 ;
var secondEle = document.getElementById("second");
var timer = setInterval(function(){
secondEle.innerHTML = time ;
time-- ;
if(time == 0){
clearInterval(timer);
location.href="http://www.mi.com";
}
}, 1000);
}
</script>
</head>
<body>
恭喜您登录成功!<span style="color:red" id="second">5</span>秒钟后跳转到指定页面!
</body>
</html>

猜你喜欢

转载自blog.csdn.net/a_jungle/article/details/80071407