zoukankan      html  css  js  c++  java
  • JSP页面实现自动跳转

    1

    <html>
    <head>
    <script language=javascript>
     function out(obj) {
      var i = obj;
      if (i == 0)
       document.location.href = "t.html";
      document.body.innerHTML = i;
      i--;
      setTimeout("out(" + i + ")", 1000);
     }
    </script>
    </head>
    <body onload="out(5)">
    </body>
    </html>

    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 一、页面自动刷新:

    把如下代码加入<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 是要跳转的页面

  • 相关阅读:
    C# 递归查找树状目录
    C#递归计算树形菜单
    使用StringBuilder写XML遭遇UTF-16问题
    Error: 'The service did not respond in a timely fashion'
    no suitable method found to override
    Could not load file or assembly "win32_x86dotnet1crdb_adoplus.dll' or one of its dependencies.
    Unable to find the requested .Net Framework Data Provider
    Call JMS Web Service
    Remove Mapping
    卸载windows服务
  • 原文地址:https://www.cnblogs.com/aabbcc/p/5130229.html
Copyright © 2011-2022 走看看