js實現頁面跳轉的幾種方式

來源:互聯網
上載者:User

標籤:www   屬性   實現   window   word   article   color   keyword   ext   

第一種:
 
    <script language="javascript" type="text/javascript">  
               window.location.href="xx.jsp?backurl="+window.location.href;   
     </script>  

另外一種:   

    <script language="javascript">  
    alert("返回");  
    window.history.back(-1); 
    window.history.go(-1)。
    </script>  


第三種:


     <script language="javascript">  
     window.navigate("xx.jsp");  
    </script>  

第四種:


    <script language="JavaScript">  
           self.location=‘xx.htm‘;  
    </script>  

第五種:


    <script language="javascript">  
           alert("非法訪問!");  
           top.location=‘xx.jsp‘;  
    </script><span style="font-size:13px;color:black;"></span>  



總結:
self:當前表單對象(假設是在iframe裡,則為該架構的表單對象)

top:父表單對象

window:典型情況下,瀏覽器會為每個開啟的html建立相應的window對象,假設這個文檔包括了多個架構,則瀏覽器會為原始文檔建立一個window對象。再為每個架構建立額外的window對象。

能夠再當前表單中直接使用window的所有屬性、方法和集合,即不須要在前面附加計算結果為當前window對象的運算式。儘管window能夠省略。可是為了方便閱讀以及避免一些漏洞,一般都使用這個keyword。


location:該對象包括當前url資訊,擁有多個屬性。預設屬性為 location.href,表示整個url,即假設設定location="http://www.ddd.cn",則等同於location.href="http://www.ddd.cn".self:當前表單對象(假設是在iframe裡,則為該架構的表單對象)

window.navigate("http://xx.html/") 這種方法是僅僅針對IE的。不適用於Firefox等其它瀏覽器,在HTML DOM Window Object中,根本沒有列出window.navigate這種方法,所以這種方法盡量少用。


window.location 屬性是相容全部瀏覽器的。

因此在實現頁面跳轉的時候這個比較經常使用。
window.history.go(-1)是返回上一頁

window.location.go(-1) 是重新整理上一頁





js實現頁面跳轉的幾種方式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.