前端獲取當前路徑

    1. //獲取當前窗口的Url    
    2. //returnUrl=http://localhost:8080/shopping/buyCart.shtml?skuId=510&amount=1  
    3.     window.location.href      
    4. //獲取當前窗口的主機名 例如:http://localhost:8080       
    5.     window.location.host              
    6. //獲取當前窗口的端口  例如: 8080  
    7. window.location.port  
    8. //獲取當前窗口的路徑 例如: /shopping/buyCart.shtml  
    9.     window.location.pathname  
    10. //獲取當前文檔的Url  
    11.     document.URL  
    12. //獲取參數  例如: ?skuId=510&amount=1  
    13. window.location.search  
    14. //跳出當前窗口,打開新窗口  
    15. window.open(url);  
    16. document默示的是一個文檔對象,window默示的是一個窗口對象,一個窗口下能夠有多個文檔對象。
      因此一個窗口下只有一個window.location.href,然則可能有多個document.URL、document.location.href
    17. window.location.href和document.location.href能夠被賦值,而後跳轉到其它頁面,document.URL只能讀不克不及寫
相關文章
相關標籤/搜索