Hello, world!
// Javascript代码
var historyState={ message: "这是一个状态对象" };
// 添加历史记录
document.getElementById("add-state").addEventListener("click", function() {
history.pushState(historyState, "添加历史记录", "/newpage.html");
});
// 修改历史记录
document.getElementById("change-state").addEventListener("click", function() {
history.replaceState(historyState, "修改历史记录", "/newpage2.html");
});
为你推荐
- 2023-07-16js reverse()(JavaScript reverse函数实现字符串翻转)
- 2023-09-14js unload(JS 卸载事件应用技巧)
- 2023-08-26js获取定位(JavaScript实现定位获取)
- 2023-09-01js反引号(使用ES6模板字面量的优势)
- 2023-09-09js thread(JavaScript线程:并行优化方案)
- 2023-07-20js 获取元素的高度(JavaScript 获取元素高度)
- 2023-09-24js版本号(更新您的JavaScript版本!)
- 2023-09-05js onunload(网页离开时触发的js onunload事件)