window.location 和 document.location 等價
改變location.href
會從新定位到一個URL,而修改location.hash
會跳到當前頁面中的anchor(<a id="name">或者<div id="id">等)名字的標記(若是有),並且頁面不會被從新加載php
經過location.search
能夠得到url中從第一個?
開始到第一個#
以前的內容
經過location.hash
能夠得到url中從第一個#
開始以後的全部內容
所以若是在?
以前存在#
,則location.search
爲空。瀏覽器
例如:
URL:http://b.a.com:88/index.php?name=kang&how=#when=2016#first
url
部分瀏覽器中,當經過接口跳轉時,如hash之外部分未改變則頁面不會從新加載,此時能夠經過加一箇中間頁面作跳轉spa