RockFeeling

          常用鏈接

          統計

          最新評論

          Javascript刷新頁面的幾種方法(摘自網絡)

          Javascript刷新頁面的幾種方法: 
          1 history.go(0) 
          2 location.reload() 
          3 location=location 
          4 location.assign(location) 
          5 document.execCommand('Refresh') 
          6 window.navigate(location) 
          7 location.replace(location) 
          8 document.URL=location.href 
          二、自動刷新頁面 
          1.頁面自動刷新:把如下代碼加入<head>區域中 
          <meta http-equiv="refresh" content="20"> 
          其中20指每隔20秒刷新一次頁面. 
          2.頁面自動跳轉:把如下代碼加入<head>區域中 
          <meta http-equiv="refresh" content="20;url=http://www.jb51.net"> 
          其中20指隔20秒后跳轉到http://www.jb51.net頁面 
          3.頁面自動刷新js版 
          <script language="JavaScript"> 
          function myrefresh() 
          window.location.reload(); 
          setTimeout('myrefresh()',1000); //指定1秒刷新一次 
          </script> 
          三、java在寫Servler,Action等程序時,要操作返回頁面的話(如談出了窗口,操作完成以后,關閉當前頁面,刷新父頁面) 
          1 PrintWriter out = response.getWriter(); 
          2 out.write("<script type=\"text/javascript\">"); 
          3 ////子窗口刷新父窗口 
          4 out.write("self.opener.location.reload();"); 
          5 //關閉窗口 
          6 out.write("window.opener=null;"); 
          7 out.write("window.close();"); 
          8 out.write("</script>"); 
          四、JS刷新框架的腳本語句 
          1.如何刷新包含該框架的頁面用 
          <script language=JavaScript> 
          parent.location.reload(); 
          </script> 
          2.子窗口刷新父窗口 
          <script language=JavaScript> 
          self.opener.location.reload(); 
          </script> 
          3.如何刷新另一個框架的頁面用 (上面的實例以說明了) 
          語句1. window.parent.frames[1].location.reload(); 
          語句2. window.parent.frames.bottom.location.reload(); 
          語句3. window.parent.frames["bottom"].location.reload(); 
          語句4. window.parent.frames.item(1).location.reload(); 
          語句5. window.parent.frames.item('bottom').location.reload(); 
          語句6. window.parent.bottom.location.reload(); 
          語句7. window.parent['bottom'].location.reload(); 
          4.如果想關閉窗口時刷新或者想開窗時刷新的話,在<body>中調用以下語句即可。 
          <body onload="opener.location.reload()"> 
          開窗時刷新 
          <body onUnload="opener.location.reload()"> 
          關閉時刷新 
          <script language="javascript"> 
          window.opener.document.location.reload() 
          </script> 

          posted on 2012-02-07 00:08 將風度養成 閱讀(179) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 泸州市| 茶陵县| 桦川县| 邮箱| 遂溪县| 乐亭县| 黄平县| 蓬安县| 静乐县| 玉林市| 镇沅| 汉阴县| 彝良县| 佛教| 青州市| 铜陵市| 台南县| 延长县| 潜江市| 蓬安县| 桐城市| 白城市| 隆子县| 宜州市| 广丰县| 延吉市| 阳城县| 清涧县| 桐庐县| 鸡西市| 舟曲县| 册亨县| 东海县| 洪湖市| 九龙城区| 卢氏县| 怀仁县| 乌拉特后旗| 和静县| 宁化县| 成都市|