HTML實現頁面自動跳轉

通過 前端頁面控制倒數5秒後跳轉到其他指點頁面

<!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.baidu.com";
			}
				
		},1000);
	}
</script>
</head>
<body>
	恭喜你,註冊成功,<span style="color:red" id="second">5</span>秒鐘後跳轉,如不跳轉點擊<a href="http://www.baidu.com">這裏</a>!
</body>
</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章