用js获取当前页面的url

1.获取当前或者指定页面的文件名或路径 window.location.pathname

2.设置或获取整个URl字符串 window.location.href

3.设置或获取URL相关的端口号 window.location.port

4.设置或获取URL的协议部分 window.location.protocol

5.获取href中"#"后面的部分 window.location.hash

6.设置或者获取URL的hostname或者port window.location.host

7.设置或者获取href属性中问号"?"后面的部分 window.location.search

原文地址:https://www.cnblogs.com/isuben/p/4234392.html