location、#、?、經過接口跳轉回原頁面時頁面未從新加載問題

location

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#firsturl

  • search
    "?name=kang&how="
  • hash
    "#when=2016#first"

經過接口跳轉回原頁面時頁面未從新加載問題

部分瀏覽器中,當經過接口跳轉時,如hash之外部分未改變則頁面不會從新加載,此時能夠經過加一箇中間頁面作跳轉spa

相關文章
相關標籤/搜索