简体   繁体   English

在浏览器导航按钮上保存网站状态

[英]Save website state on browser navigation buttons

I have reg forms which have next and previous buttons and switch sections (showing and hiding them) with jQuery. 我有带有下一个和上一个按钮以及使用jQuery切换部分(显示和隐藏它们)的注册表。 I saw all plugins are using # tag and routes , but I can't use that. 我看到所有插件都使用#标签和路由,但是我不能使用它。 Is it possible to save this action somehow? 是否可以某种方式保存此动作? For example, when I click back in the browser it needs to do the same action as when I click on the back button on the form. 例如,当我在浏览器中单击后,它需要执行与单击表单上的后退按钮相同的操作。 Is there any way to do this? 有什么办法吗?

You could try this jQuery Code: 您可以尝试以下jQuery代码:

$(window).on("navigate", function (event, data) {
  var direction = data.state.direction;
  if (direction == 'back') {
    // do something
  }
  if (direction == 'forward') {
    // do something else
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM