js 读秒后自动跳转

错误处理页面,倒数十秒后自动跳转页面。
刚开始没有考虑适应火狐和chrome被个小子嘲笑了一下,告诉我不好用,尼玛。

代码如下
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<jsp:include page="common/common.jsp"></jsp:include>
<!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 >
<div id="CID" >
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
    <!--单位:秒-->
         系统异常,十秒后自动跳转到登录页面:<span id="endtime">10</span>
         <br/>
         <a href = "page/userexit.jsp">
         点击跳转登录页面
         </a>
    </td>
  </tr>
</table>
</div>
</body>
<script type="text/javascript">
var id = 	setInterval(function(){
	if(navigator.userAgent.indexOf("MSIE")>0) {
      var obj = document.getElementById('endtime');
        var num = parseInt(obj.innerHTML);
        if(num<=0){
     		 window.location.href= basePath + "page/userexit.jsp";
     	}
			    obj.innerHTML = num-1;
	}else if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
		     var obj = document.getElementById('endtime');
     var num = parseInt(obj.textContent);
     if(num<=0){
     		 window.location.href= basePath + "page/userexit.jsp";
     	}
	       obj.textContent = num-1;
	} else{
		var obj = document.getElementById('endtime');
        var num = parseInt(obj.innerHTML);
        if(num<=0){
     		 window.location.href= basePath + "page/userexit.jsp";
     	}
			    obj.innerHTML = num-1;
	}
	},1000);
	
setTimeout(function(){
window.location.href = basePath + "page/userexit.jsp";
clearInterval(id);
},10000);
</script>
</html>


小宝制造。

你可能感兴趣的:(js,自动跳转)