index.jsp页面code
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
var Url;
var sec = 8;
function Load(url){
Url = url;
for(var i=sec;i>=0;i--){
window.setTimeout('doUpdate('+i+')',(sec-i)*1000);
}
}
function doUpdate(num){
document.getElementById("showMsg").innerHTML='您尚未登录或登录信息已经过期,系统将在<strong>'+num+'</strong>秒后自动跳转到登陆页面';
if(num==0){
window.location=Url;
}
}
function forwards(){
window.history.go(1);
}
</script>
</head>
<body>
<div id="showMsg"></div>
<a href="mag.jsp">立即跳转</a>
<script type="text/javascript">
Load("mag.jsp");
</script>
<button οnclick="forwards()">前进</button>
</body>
</html>
mag.jsp页面code
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
function forwards(){
window.history.go(-1);
}
</script>
</head>
<body>
欢迎光临!
<button οnclick="forwards()">返回</button>
</body>
</html>