<轉>HTML meta refresh 刷新與跳轉(重定向)頁面


下面為各位整理了一些HTML meta refresh 刷新與跳轉(重定向)頁面的例子吧,后面本站長自己也補充了一些js頁面刷新與跳轉例子吧。
 

refresh 屬性值  --  刷新與跳轉(重定向)頁面

refresh用於刷新與跳轉(重定向)頁面

refresh出現在http-equiv屬性中,使用content屬性表示刷新或跳轉的開始時間與跳轉的網址


refresh示例

5秒之后刷新本頁面:

<metahttp-equiv="refresh"content="5"/>

5秒之后轉到夢之都首頁:

<metahttp-equiv="refresh"content="5; url=http://www.111cn.net/"/>

當然除了這些方法還有js也可以跳轉與刷新了,下面既然講到這個刷新頁面了我們就再看看js補充吧

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

js頁面跳轉

1.window.location.href方式
    <script language="javascript" type="text/javascript">
           window.location.href="target.aspx";
    </script>

2.window.navigate方式跳轉
   <script language="javascript">
    window.navigate("target.aspx");
</script>

 

3.window.loction.replace方式實現頁面跳轉,注意跟第一種方式的區別
<script language="javascript">
    window.location.replace("target.aspx");
</script>
有3個jsp頁面(1.aspx, 2.aspx, 3.aspx),進系統默認的是1.aspx,當我進入2.aspx的時候, 2.aspx里面用window.location.replace("3.aspx");

與用window.location.href ("3.aspx");

從用戶界面來看是沒有什么區別的,但是當3.aspx頁面有一個"返回"按鈕,調用window.history.go(-1); wondow.history.back();方法的時候,一點這個返回按鈕就要返回2.aspx頁面的話,區別就出來了,當用 window.location.replace("3.aspx");連到3.aspx頁面的話,3.aspx頁面中的調用 window.history.go(-1);wondow.history.back();方法是不好用的,會返回到1.aspx。

4.self.location方式實現頁面跳轉,和下面的top.location有小小區別
   <script language="JavaScript">
          self.location='target.aspx';
   </script>

5.top.location
   <script language="javascript">
          top.location='target.aspx';
   </script>

 

6.不推薦這種方式跳轉
    <script language="javascript">
    alert("返回");
    window.history.back(-1);
   </script>

 meta方式實現跳轉(content = 3 單位是秒)
<meta http-equiv=refresh content=3;URL="http://www.111cn.net">


免責聲明!

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



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