jQuery的时候后退按钮是pressed [英] Jquery when back button is pressed

查看:125
本文介绍了jQuery的时候后退按钮是pressed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个点击,当你点击它,改变页面上的东西。我在想,如果有,当你美元的浏览器p $ PSS后退按钮来触发效果的一种方式。

I have a click that changes things on the page when you click it. I was wondering if there was a way to trigger an effect when you press the back button on the browser

推荐答案

您可以排序的做到这一点使用popstate事件:

You can sort of do it using the popstate event:

window.onpopstate = function() {
  alert("pop!");
}

的jQuery

$(window).on('popstate', function(event) {
 alert("pop");
});

不过,这也将向前航行时,不仅落后触发。

However this will also trigger when navigating forward, not only backward.

这篇关于jQuery的时候后退按钮是pressed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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