我怎么知道,如果用户点击"返回]按钮?按钮、我怎么、用户、QUOT

2023-09-11 01:28:26 作者:凉冬空巷°

我使用的锚具有独特的URL处理一个ajaxy网站。不过,我想,当用户点击浏览器的后退按钮,这样的内容总是匹配的网址重新加载内容。

I'm using anchors for dealing with unique urls for an ajaxy website. However, I want to reload the content when the user hits the Browser's "back" button so the contents always matches the url.

我怎样才能做到这一点?是否有一个jQuery的事件,当用户点击后退?

How can I achieve this? Is there a jQuery event triggering when user clicks "Back"?

推荐答案

您需要使用hashchange事件。有几个流行的插件。我一直在使用的地址插件,喜欢它。有些人会认为烧烤也。

You need to use a hashchange event. There are a couple of popular plugins. I've been using the address plugin and like it. Some will suggest BBQ also.

地址插件

jQuery的烧烤