`

在jsp中实现页面定时跳转的方法总结

阅读更多

第一种:

response.setHeader("Refresh", "5; URL=http://www.google.com"); //5秒后,当前页面跳转到google。

 

第二种:

JSP 如何实现网页定时跳转:

<script   language="javascript">  
  <!--  
  setTimeout("document.location.href='http://www.163.com'",3000);  
  //-->  
  </script>

刷新:

<meta   http-equiv="Refresh"   content="xxx;yyy.jsp"/>  
  xxx是秒数  
  xxx秒之后就会跳转到yyy.jsp

 

第三种:

<% String url=request.getParameter("url") ;%>

<SCRIPT LANGUAGE="JavaScript">
<!--
var time = 3; //时间,秒

function Redirect(){
window.location ="<%=url %>";
}
var i = 0;
function dis(){
document.all.s.innerHTML = "还剩" + (time - i) + "秒";
i++;
}
timer=setInterval('dis()', 1000);//显示时间
timer=setTimeout('Redirect()',time * 1000); //跳转

//-->
</SCRIPT>
</head>
<body>
<span id="s"></span>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics