如何在当前路径中保存"window history state"?



我需要保存"窗口历史状态";在当前路径中,例如{offset: 10}。然后我可以转到另一个路径,在我返回(location.back())之后,我得到了保存状态为({offset: 10})的前一个路径我怎样才能拯救国家?提前谢谢。

我想你正在寻找推送状态(history.pushState(state, title, [,url]))。他是一个例子:

history.pushState(null, null, "my-page.html?offset=10";

Ref = https://www.javascripttutorial.net/web-apis/javascript-history-pushstate/

最新更新