当前位置: 代码迷 >> JavaScript >> jsp实现数目字倒计时后页面自动跳转
  详细解决方案

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

热度:305   发布时间:2013-11-09 17:06:41.0
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>

  相关解决方案