xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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

原文地址:https://www.cnblogs.com/xgqfrms/p/10564735.html