w3schools : The Location Object
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>location相关测试</title>
<style>
#J_Location {
line-height: 2.35em;
font-size: .875em;
}
</style>
</head>
<body>
<div id="J_Location"></div>
<script>
var alertStr = 'location : ' + location + '<br>' +
'location.pathname : ' + location.pathname + '<br>' +
'location.host : ' + location.host + '<br>' +
'location.hostname : ' + location.hostname + '<br>' +
'document.URL : ' + document.URL + '<br>' +
'location.href : ' + location.href + '<br>' +
'location.protocol : ' + location.protocol + '<br>' +
'location.origin : ' + location.origin + '<br>' +
'location.search : ' + location.search + '<br>' +
'location.hash : ' + location.hash
//hash -Sets or returns the anchor portion of a URL.
//host -Sets or returns the hostname and port of a URL.
//hostname -Sets or returns the hostname of a URL.
//href -Sets or returns the entire URL.
//pathname -Sets or returns the path name of a URL.
//port -Sets or returns the port number the server uses for a URL.
//protocol -Sets or returns the protocol of a URL.
//search -Sets or returns the query portion of a URL
//hash 设置或返回从井号 (#) 开始的 URL(锚)。
//host 设置或返回主机名和当前 URL 的端口号。
//hostname 设置或返回当前 URL 的主机名。
//href 设置或返回完整的 URL。
//pathname 设置或返回当前 URL 的路径部分。
//port 设置或返回当前 URL 的端口号。protocol 设置或返回当前 URL 的协议。
//search 设置或返回从问号 (?) 开始的URL(查询部分) 。
document.getElementById('J_Location').innerHTML = alertStr;
</script>
</body>
</html>