JSP頁面自動刷新


1.頁面自動刷新:把如下代碼加入<head>區域中
<meta http-equiv="refresh" content="20">,其中20指每隔20秒刷新一次頁面.


2.頁面自動跳轉:把如下代碼加入<head>區域中
<meta http-equiv="refresh" content="20;url=http://www.abc.com">,其中20指隔20秒后跳轉到http://www.abc.com頁面


3.頁面自動刷新js版
<script language="JavaScript">
function myrefresh(){
   window.location.reload();
}
setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>

4.用setHander()方法

<%
//頁面每隔30秒自動刷新一遍 
response.setHeader("refresh","30");
%>

<%      


//頁面每隔30秒自動鏈接至另一頁面   

 response.setHeader("refresh","30;URL=http://www.sina.com");

%> 

  

<%@ page contentType="text/html;charset=GBK" %>
<%
  //頁面每隔30秒自動刷新一遍    
  response.setHeader("refresh","10;URL=http://www.sina.com");

%>
<html>
  <head>
    <title>My JSP 'index.jsp' starting page</title>
    <!--  <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="refresh" content="30"> -->
    <script type="text/javascript">
       alert("jsp");
    </script>
  </head>
  
  <body>
    This is my JSP page. <br>
  </body>
</html>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM