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 >

 

转载于:https://www.cnblogs.com/HRuinger/p/5686830.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值