Jsp和js倒计时跳转页面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();//得到项目的名字
String basePath = request.getScheme()+"://"+request.getServerName()+":"
+request.getServerPort()+path;//服务器端的路径
%>
<%
String url = basePath+"/user/registerView";
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${webSite.webSiteName}邮箱激活</title>
<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/common.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/index.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/other.css" />
<script src="<%=basePath%>/js/jquery/jquery-1.7.2.min.js"type="text/javascript"></script>
<script type="text/javascript">var t = 3; //设置一个跳转秒数$(function(){ setInterval("count()",1000); //定义一个定时器 $("#timeCount").html(t); //显示当前的秒数});function count(){ t--; //秒数自减 if(t >= 0){ /* alert(location.href); alert(window.location.host+window.location.pathname); */ $("#timeCount").html(t); //刷新当前的秒数,重新显示秒数 }else{ window.location.href=getRootPath()+"/user/registerView"; // 设置跳转的链接 }}//js获取项目根路径,如: http://localhost:8080/ivcfunction getRootPath(){//获取当前网址,如: http://localhost:8080/ivc/share/meun.jspvar curWwwPath=window.document.location.href;//获取主机地址之后的目录,如: ivc/share/meun.jspvar pathName=window.document.location.pathname;var pos=curWwwPath.indexOf(pathName);//获取主机地址,如: http://localhost:8080var localhostPaht=curWwwPath.substring(0,pos);//获取带"/"的项目名,如:/ivcvar projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);return(localhostPaht+projectName);}</script>
</head><body> <jsp:include page="header.jsp"></jsp:include> <!--中心content Start--> <div class="content widthCom warp marginCenter"> <div class="activateCont"> <img src="<%=basePath%>/images/error_icon.png" /><h3>链接失效,请重新注册</h3><br /> <span id="timeCount" style="color:red"></span>秒钟后页面将自动返回注册页面...</b> </div> </div> <!--中心content End--> <jsp:include page="footer.jsp"></jsp:include></body></html>