window.location.href/replace/reload()--頁面跳轉+替換+重新整理

來源:互聯網
上載者:User

標籤:blog   http   io   os   使用   java   ar   sp   log   

原文地址:http://jun1986.iteye.com/blog/1176909

------------------------------------------------------------------------------------------------------------------------------------------------------------------

一、最外層top跳轉頁面,適合用於iframe框架組

top.window.location.href("${pageContext.request.contextPath}/Login_goBack");

============================================================================================

二、window.location.href和window.location.replace的區別 

1.window.location.href=“url”:改變url地址; 

2.window.location.replace(“url”):將地址替換成新url,該方法通過指定URL替換當前緩衝在歷史裡(用戶端)的項目,
因此當使用replace方法之後,你不能通過“前進”和“後 退”來訪問已經被替換的URL,這個特點對於做一些過渡頁面非常有用!

三、強制頁面重新整理 

1.window.location.reload():強制重新整理頁面,從伺服器重新請求! 

============================================================================================

四、window.location.reload();頁面實現跳轉和重新整理 

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
這幾個都可以重新整理
window.location.reload();重新整理
window.location.href=window.location.href;重新整理
window.close();關閉視窗,不彈出系統提示,直接關閉 
window.close()相當於self屬性是當前視窗
window.parent.close()是parent屬性是當前視窗或架構的架構組
頁面實現跳轉的九種方法執行個體:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>navigate</title>
<script language="javascript">
    setTimeout(‘window.navigate("top.html");‘,2000);
    setTimeout(‘window.document.location.href="top.html";‘,2000);
    setTimeout(‘window.document.location="top.html";‘,2000);
    setTimeout(‘window.location.href="top.html";‘,2000);
    setTimeout(‘window.location="top.html";‘,2000);
    setTimeout(‘document.location.href="top.html";‘,2000);              
    setTimeout(‘document.location="top.html";‘,2000);
    setTimeout(‘location.href="top.html";‘,2000);
    setTimeout(‘location.replace("top.html")‘,2000);
    //window對象
        //document對象
            //location對象
                //href屬性
                //1.window.document.location.href
                //2.window.document.location
                //3.window.location.href
                //4.window.location
               
                //5.document.location.href
                //6.document.location
                //7.location.href
                //8.window.navigate
                //9.location.replace
                //只要使用location方法,和任意的window對象,location對象,href屬性連用,都可以頁面的跳轉//// 
</script>
</head>

<body>
頁面將在2秒後跳轉
</body>
</html>

解釋:
location是個對象,比如本頁的document.location和window.location的屬性有    
  location.hostname   =   community.csdn.net 
  location.href   =   http://community.csdn.net/Expert/topic/4033/4033372.xml?temp=2.695864E-02 
  location.host   =   community.csdn.net 
  location.hash   =   
  location.port   =   
  location.pathname   =   /Expert/topic/4033/4033372.xml 
  location.search   =   ?temp=2.695864E-02 
  location.protocol   =   http: 
  可見href是location的屬性,類別是string。

 

window.location.href/replace/reload()--頁面跳轉+替換+重新整理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.