location中的各个属性

 

 

 

http://172.16.20.218:8080/m/MGU20201126001-001/index.html?username=admin&password=123#/write   
浏览器输入这个链接,这个url中location的属性如下:

hash: "#/write"
host: "172.16.20.218:8080"
hostname: "172.16.20.218"
href: "http://172.16.20.218:8080/m/MGU20201126001-001/index.html#/write"
origin: "http://172.16.20.218:8080"
pathname: "/m/MGU20201126001-001/index.html"
port: "8080"
protocol: "http:"
search: "?username=admin&password=123"

 

小窍门  :

  需要获取当前url 不需要参数的话,那就是   location.origin+location.pathname

  需要获取当前 完整的url,那就是   location.href

posted @ 2021-01-18 13:56  大熊丨rapper  阅读(115)  评论(0编辑  收藏  举报