首页 > 技术文章 > js获取当前url

ncellit 2018-12-12 14:11 原文

 

1、window.location.href(设置或获取整个 URL 为字符串)

2、window.location.protocol(设置或获取 URL 的协议部分)

3、window.location.host(设置或获取 URL 的主机部分)

4、window.location.port(设置或获取与 URL 关联的端口号码)

5、window.location.pathname(设置或获取与 URL 的路径部分(就是文件地址))

6、window.location.search(设置或获取 href 属性中跟在问号后面的部分)

7、window.location.hash(设置或获取 href 属性中在井号“#”后面的分段)

参考地址:https://www.cnblogs.com/zhabayi/p/6419938.html

推荐阅读