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