js获取当前路径的url

//获取当前窗口的Url    
//returnUrl=http://localhost:8080/shopping/buyCart.shtml?skuId=510&amount=1  
    window.location.href      
//获取当前窗口的主机名 例如:http://localhost:8080       
    window.location.host              
//获取当前窗口的端口  例如: 8080  
window.location.port  
//获取当前窗口的路径 例如: /shopping/buyCart.shtml  
    window.location.pathname  
//获取当前文档的Url  
    document.URL  
//获取参数  例如: ?skuId=510&amount=1  
window.location.search  
//跳出当前窗口,打开新窗口  
window.open(url);  

你可能感兴趣的:(Javascript)