使用JS完成页面定时跳转

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
*//页面加载*
	window.onload = function(){
		var secondEle = document.getElementById("second");
		var time = 5;
	var timer = setInterval(function(){
		secondEle.innerHTML = time;
		time--;
		if(time==0){
			clearInterval(timer);
			location.href="http://www.baidu.com"
		}	
	},1000)
	}
</script>
</head>
<body>
	恭喜您,注册成功,<span style="color:red" id="second">5</span>秒后跳转,如不跳转点击<a href="http://www.souhu.com">这里</a>!
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_44079964/article/details/85252885