在History.js中有没有办法知道何时按下后退按钮 [英] Is there a way in History.js to know when the back button was pressed

查看:99
本文介绍了在History.js中有没有办法知道何时按下后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已开始测试 History.js 。在了解它是如何工作以及没有 popstate 之后,而是 statechange 。我正在寻找一种方法,以便在按下浏览器的后退按钮时有所不同。

I've started to test History.js. After understanding how it works and that there is no popstate, instead there is statechange. I'm looking for a way to differ when the back button of the browser has been pressed.

原因是我需要在状态移动之前知道URL,从我要去的那个。使用项目包含的要点,只查看我们访问的网址。

The reason is that I need to know the URL before the state moved, from the one I'm going to. With the gist the project includes, only the URL we go to is looked.

我希望解决方案不是跟踪全局变量中访问的最新URL。

I hope the solution is not to track latest URL visited in a global variable.

谢谢

推荐答案

我终于使用 History.pushState 管理所有链接,这样就不需要按下后退按钮了。我们以同样的方式处理所有状态更改。

I finally managed all links using History.pushState, that way there is no need to differ a back button pressed. We handle all state changes the same way.

编辑:在History.js'Github中找到这两个问题,可能对某人有帮助。
https://github.com/browserstate/history.js/issues/70
https://github.com/browserstate/history.js / issues / 47

Found these two issues in History.js' Github, might help someone. https://github.com/browserstate/history.js/issues/70 https://github.com/browserstate/history.js/issues/47

这篇关于在History.js中有没有办法知道何时按下后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆