`

jsp实现数字倒计时后页面自动跳转

 
阅读更多

在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 %>>           
           </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>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics