实现起来很简单,注意
1.在头部加
<meta http-equiv="refresh" content="3;url=../login.jsp">
2.在javascript加:
<script type="text/javascript">
<!--最初的时间-->
var time = 4;
<!--动态时间的显示函数-->
function returnUrlByTime() {
<!--每隔1秒调用该函数-->
window.setTimeout('returnUrlByTime()', 1000);
<!--时间递减-->
time = time - 1;
<!--显示动态时间的层-->
document.getElementById("layer").innerHTML = time;
}
</script>
3.在页面加:
<div id="layer">3</div>秒后跳转到登录页面,如果没有跳转请点击<a href="login.jsp">这里</a>
这是原页面的Code:
- <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <base href="<%=basePath%>">
- <title>错误</title>
- <meta http-equiv="refresh" content="3;url=../login.jsp">
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
- <meta http-equiv="description" content="This is my page">
- <!--
- <link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css">
- -->
- <mce:script type="text/javascript">
- <!--最初的时间-->
- var time = 4;
- <!--动态时间的显示函数-->
- function returnUrlByTime() {
- <!--每隔1秒调用该函数-->
- window.setTimeout('returnUrlByTime()', 1000);
- <!--时间递减-->
- time = time - 1;
- <!--显示动态时间的层-->
- document.getElementById("layer").innerHTML = time;
- }
- // --></mce:script>
- </head>
- <body onload="returnUrlByTime()">
- <div>
- <center><%=request.getAttribute("message") %></center>
- <center><div id="layer">3</div>秒后跳转到登录页面,如果没有跳转请点击<a href="login.jsp" mce_href="login.jsp">这里</a></center>
- </div>
- </body>
- </html>