在Javascript中,perferably JQuery的,我怎么添加的东西到URL当用户点击"返回]在浏览器按钮? [英] In Javascript, perferably JQuery, how do I add something to the URL when the user clicks "back" button in the browser?

查看:223
本文介绍了在Javascript中,perferably JQuery的,我怎么添加的东西到URL当用户点击"返回]在浏览器按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在浏览器中点击返回按钮,我想追加&放大器;页= 3的URL。
我怎么绑定,然后再做到这一点?

When the browser clicks "back" button, I want to append "&page=3" to the URL. How do I bind it, and then do this?

编辑:我想这个很简单。

I want this very simple.

BIND the event{
window.location(that-url + "&page=3")
}

能不能做到,根本?

Can it be done that simply?

推荐答案

这听起来像你想创造一个历史的插件。

It sounds like you're trying to create a history plugin.

您是否尝试过使用御影史插件使用?

Have you tried using using the mikage history plugin?

我不建议更改URL,当他们从浏览当前页面(也就是后退按钮做什么)了,因为你马上清除前进历史(从而打破了前进按钮)。当试图处理与分页和JavaScript后退按钮/ AJAX更典型使用浏览器的哈希来传递参数。当使用向前和向后按钮JavaScript的空间不会被清除,并且散列是根据使用了什么导航更新。这些历史插件有几个方法时,导航使用(如DOC负载不会触发事件)来检测。

I wouldn't recommend changing the URL when they navigate away from the current page (which is what the back button does), because you immediately erase the forward history (thus breaking the forward button). When trying to handle the back button with pagination and javascript/ajax it is more typical to use the browser hash to pass parameters. The JavaScript namespace doesn't get cleared when the forward and backward buttons are used and the hash is updated according to what navigation was used. These history plugins have a couple of methods to detect when navigation is used (as the doc load event doesn't fire).

所以要小心,书写历史的插件,因为浏览器无法一致地处理的位置对象的hash属性(窗口对象的一部分)的方法并不简单。你一定会想看看别人怎么做的。

So beware, writing a history plugin isn't straightforward because of the way browsers fail to consistently handle hash property of the location object (part of the window object). You will definitely want to look at what others have done.

这篇关于在Javascript中,perferably JQuery的,我怎么添加的东西到URL当用户点击"返回]在浏览器按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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