删除使用jQuery浏览器历史记录 [英] Delete browser history using jQuery

查看:1235
本文介绍了删除使用jQuery浏览器历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于jQuery的Ajax应用程序。我使用的 jQuery的记录插件启用浏览器的历史记录。但是,我们发现,应用程序生成的过多的历史。

I have an ajax application that is based on jQuery. I enabled browser history using jQuery history plugin. But we find out that the application generated too much history.

特别是,我们提供了一个在网页Ajax的后退按钮,使该页面返回previous阿贾克斯状态。当在网页Ajax的后退按钮是pressed,我们希望它像的broswer后退按钮,通过移动历史的当前索引,或删除的最新历史记录,插入新的历史instand记录。

Especially, we provide an in-page "ajax-back" button that enable the page to return to previous ajax state. When the in-page "ajax-back" button was pressed, we want it to act like the broswer back button, by moving the current index of the history, or removing the latest history record, instand of inserting a new history record.

所以,我想问一下,是否有可能从javascript除去最新的浏览器记录吗是它可以修改浏览器历史记录列表的当前索引?

So, I would like to ask, is it possible to remove the latest browser record from javascript? or is it possible to modify the current index of the browser history list?

这是基于jQuery插件历史的例子将是非常美联社preciated。

Examples that are based on jQuery history plugin will be very appreciated.

推荐答案

最有可能你不能轻易做你尝试的东西。有window.location.replace,都到一个新的URL,并从历史的当前页面,但是这对整个页面导航,并几乎肯定会打破伪造历史的jQuery的方式。

Most likely you can't easily do what you're attempting. There is window.location.replace, which goes to a new URL and removes the current page from the history, but that's for full page navigations and will almost certainly break jQuery's way of faking history.

有可能改变,其中在历史堆栈你是,使用window.history.go(),这需要一个整数偏移历史并且导航到相关条目。它不会修改堆栈可言,它只是让你在一个新的地方。也有回()和远期(),它只是调用分别-1,1走功能。这可能是你在找什么,但它不会修改堆栈,只需将你周围的吧。

It is possible to change where in the history stack you are, using window.history.go(), which takes an integer offset into history and navigates to the relevant entry. It doesn't modify the stack at all, it just puts you in a new place. There are also back() and forward() functions which just call go with -1 and 1 respectively. This is probably what you're looking for, though it won't modify the stack, just move you around in it.

在理想情况下,你会发现的jQuery插件不维护历史jQuery.history的方式做,而是提供了一个抽象onhashchange,你的图书馆将刚反应过来凑变化。这样一来,浏览器负责历史堆栈的,你不会碰到很多的问题,疯狂的那条狗Ajaxian的历史库。

Ideally, you'd find a plugin for jQuery that doesn't maintain history the way jQuery.history does, but instead offers an onhashchange abstraction, and your library would just react to hash changes. That way, the browser is in charge of the history stack and you won't run into a lot of the crazy issues that dog ajaxian history libraries.

这篇关于删除使用jQuery浏览器历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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