Skip to content

Instantly share code, notes, and snippets.

@lazyjerry
Created August 6, 2020 15:59
Show Gist options
  • Save lazyjerry/8c17be7ff25475cda624c8fda943922c to your computer and use it in GitHub Desktop.
Save lazyjerry/8c17be7ff25475cda624c8fda943922c to your computer and use it in GitHub Desktop.
執行window.history.pushState
參考:http://frontenddev.org/article/html-5-pushstate-popstate-operating-history-no-refresh-to-change-the-current-url.html
// 當前的url為:http://qianduanblog.com/index.html
var json={time:new Date().getTime()};
// @狀態對象:記錄歷史記錄點的額外對象,可以為空
// @頁面標題:目前所有瀏覽器都不支持
// @可選的url:瀏覽器不會檢查url是否存在,只改變url,url必須同域,不能跨域
window.history.pushState(json,"","http://qianduanblog.com/post-1.html");</pre>
執行了pushState方法後,頁面的url地址為http://qianduanblog.com/post-1.html。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment