第一種:
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>