js获取当前路径的url

Posted Ashan-Da宝旗

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);

以上是关于js获取当前路径的url的主要内容,如果未能解决你的问题,请参考以下文章