HTML5 History API & URL 重定向


HTML5 History API & URL 重定向

disabled server url redirect

https://developer.mozilla.org/en-US/docs/Web/API/History_API

https://css-tricks.com/using-the-html5-history-api/

window.history.back();
window.history.go(-1);


window.history.forward();
window.history.go(1);

window.history.go(0);//the same like:
window.history.go();


let numberOfEntries = window.history.length;

let currentState = history.state;

history.pushState() & history.replaceState()


let stateObj = {
    foo: "bar",
};
​​​​​​​
history.pushState(stateObj, "page 2", "bar.html");

history.replaceState(stateObj, "page 3", "bar2.html");

demo

https://developer.mozilla.org/zh-CN/docs/Web/API/History_API/Example

https://developer.mozilla.org/en-US/docs/Web/API/History_API


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM