jsp实现页面自动跳转

来源:互联网 发布:两个表筛选重复数据 编辑:程序博客网 时间:2024/04/30 21:13
1.<script language=javascript>
function out(obj){
var i = obj ;
if(i==0)
document.location.href="othorpage";
document.body.innerHTML = i;
i--;
setTimeout("out("+i+")",1000);
}
</script>
<body onload="out(5);">
</body>
2.
<%response.setHeader("Refresh","5;URL=...");%>
3.
<META   HTTP-EQUIV="REFRESH"   CONTENT="2";url=xxxx.jsp">
4.
jsp实现页面自动跳转
对于网站的用户注册模块考虑如下:当用户注册成功以后,把注册信息显示给用户,然后从这个页面自动跳转到登录页面,要求在指定时间之内,并且,用户可以看到倒计时的显示效果,具体控制实现的方法如下:<%
      String path = request.getContextPath();
      String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><%
      String url = basePath+"login.jsp";
%><html>
        <head>               <meta http-equiv=refresh content=5;url=<%=url %>>             <script>
              <!--
                   window.moveTo(0,0);
             //-->
             </script>        </head>
       <body >               <b style=color:blue><span id=jump>5</span> 秒钟后页面将自动返回登录页面...</b>        </body>
</html>           <script>
                      function countDown(secs){
                           jump.innerText=secs;
                           if(--secs>0)
                                    setTimeout("countDown("+secs+" )",1000);
                    }
                     countDown(5);
            </script>


JSP页面实现自动跳转!
关键字: JSP
一、页面自动刷新:
把如下代码加入<head>区域中
<meta http-equiv="refresh" content="5">
注:content="5" 是时间控制,表示每隔5秒刷新一次页面。
二、页面自动跳转:
把如下代码加入<head>区域中
<meta http-equiv="refresh" content="1;url=index.jsp">
注:content="1 是时间控制,表示1秒后自动跳转到要跳转的页面.
      content="0 表示打开该页后立即跳转到你要跳转的页面.
      url=index.jsp 是要跳转的页面