JavaScript中window.location对象属性的各类用法

href = "https://www.shuku.top:8080/demo/test.html?name=123#678";

//返回URL瞄点部分,也就是链接中#号后面的参数,
var a = window.location.hash;
a = #678

//返回URL主机名和端口
var b = window.location.host;

b = www.shuku.top:8080

//返回URL主机名
var c = window.location.hostname;
c = www.shuku.top

//返回完整的URL
var d = window.location.href;
d = https://www.shuku.top:8080/demo/test.html?name=123#678

//返回URL路径名,
var e = window.location.pathname;
e = /demo/test.html

//返回URL服务器使用的端口号,如果端口号是默认的80端口,则不会返回
var f = window.location.port;
f = 8080

//返回URL协议
var g = window.location.protocol;
g = https:

//返回URL的查询部分
var h = window.location.search;
h = name=123