倒计时跳转

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册失败</title>
</head>
<body>
	<p style="color:red;">注册失败,用户名以存在!</p>
	<p><strong><span id="sendRedirect">5</span><span>秒后返回首页</span></strong>,如想重新注册请点击<a href="register.jsp">注册</a></p>
  <script type="text/javascript">  
    var num=document.getElementById('sendRedirect').innerHTML;
	//获取显示秒数的元素,通过定时器来更改秒数。
	function te(){		
		document.getElementById('sendRedirect').innerHTML=num; 
			num--;
			if(num==0){
				location.assign("index.jsp");
				//通过window的location和history对象来控制网页的跳转。
			}
	}
	setInterval("te()",1000);    
 </script> 
</body>
</html>
原文地址:https://www.cnblogs.com/caoleiCoding/p/9124961.html