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

那时候我只有一台录音机也没有电脑 也不敢奢求说唱会让自己的生活变好
原文地址:https://www.cnblogs.com/520BigBear/p/14292356.html