Created
August 6, 2020 15:59
-
-
Save lazyjerry/8c17be7ff25475cda624c8fda943922c to your computer and use it in GitHub Desktop.
執行window.history.pushState
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
參考: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