JSP中如何利用JS实现登录页面的跳转(JSP中如何利用JS实现跳转页面)

JSP中如何利用JS实现登录页面的跳转(JSP中如何利用JS实现跳转页面)

 注:只是用到js中的setTimeout();具体使用方法:

  setTimeout(函数名, 时间(毫秒));

 setTimeout( ) 是属于 window 的 method, 但我们都是略去 window 这顶层物件名称, 这是用来设定一个时间, 时间到了, 就会执行一个指定的 method。setTimeout( ) 通常是与 function一起用.

样例:

  1 <%@ page language="java" contentType="text/html; charset=UTF-8"

 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 7 <title>Login the System Information.</title>
 8 </head>
 9 <body>
10     <h1 align="center">Login the System Information.</h1>
11 
12     <%!String url = null;
13     String word = null;%>
14     <%
15         String tag = (String) request.getSession().getAttribute("tagToMBoard");
16         if (tag == "0") {
17             url = "/HRuinger/index.jsp";
18             word = "你输入的用户信息不正确,请你核对后重新输入!正在为你转到登录页面.";
19         }
20         if (tag == "1") {
21             url = "/HRuinger/messageBoard.jsp";
22             word = "你输入的验证码不正确,请你核对后重新输入!正在为你转到登录页面.";
23         }
24         if (tag == "2") {
25             url = "/HRuinger/messageBoard.jsp";
26             word = "你已登录,欢迎你的使用!正在为你转到主界面.";
27         }
28     %>
29 
30     <h3 align="center">
31         <href=<%=url%>><%=word%></a>
32     </h3>
33 
34 </body>
35 </html>
36 <script type="text/javascript">
37     function jumpurl(){
38         window.location="<%=url%>";
39     }
40     setTimeout('jumpurl()', 4000);
41     </script>

 

posted @ 2016-07-20 00:59  HRuinger  阅读(1390)  评论(0编辑  收藏  举报