hash | 返回URL中锚部分,即#以及#之后的部分 |
host | 返回主机名以及端口 |
hostname | 返回主机名 |
href | 返回完整的URL |
pathname | 返回URL路径名,即主机名后第一个斜杠及其以后部分 |
port | 返回端口 |
protocol | 返回URL使用的协议(如https:) |
search | 返回查询部分,即问号及其以后部分 |
附上关于hash的一个小栗子
<html>
<head>
<title>
Location
</title>
<script type="text/javascript">
function toYellow(){
location.hash="#yellow";
document.write(location.host);
document.write(location.host);
document.write(location.host);
document.write(location.host);
}
</script>
</head>
<body>
<button οnclick="toYellow()">click me to yellow one</button>
<div id="red" style="background: red; width: 400px; height:400px;">
this is a red div
</div>
<div id="blue" style="background: blue; width: 400px; height:400px;">
this is a blue div
</div>
<div id="yellow" style="background: yellow; width: 400px; height:400px;">
this is a yellow div
</div>
</body>
</html>