在 JQuery 中进行 URL 哈希/历史记录的最佳库是什么?

发布于 2024-08-23 18:17:05 字数 1536 浏览 12 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

生死何惧 2024-08-30 18:17:05

我最近查看了 3 个不同的插件 - jquery 历史记录插件历史jQuery BBQ

它们都很难设置,我确实让 jQuery.history 工作了,但在 IE7 上仍然有问题。所以我改用 BBQ,它在我们所有的目标浏览器(IE6、IE7、IE8、Fx3)上运行良好。

所以我推荐 jQuery BBQ 插件。

编辑: 这是我刚刚写的一篇博客文章,它演示了带有级联下拉菜单的 jQuery BBQ。

I recently looked at 3 different plugins - jquery history plugin, history, and jQuery BBQ.

They were all quite hard to setup, I did get jQuery.history working but it still had problems with IE7. So I changed to BBQ and it worked fine across all our target browsers (IE6, IE7, IE8, Fx3).

So I recommend the jQuery BBQ plugin.

Edit: here's a blog post I just wrote which demonstrates jQuery BBQ with cascading dropdowns.

蓝戈者 2024-08-30 18:17:05

你尝试过 jQuery 地址吗?来自 Asual,SWFAdress 的制作者。 常规 - jquery 地址

jQuery Address 插件提供强大的深度链接功能,并允许创建可以指向网站部分或应用程序状态的唯一虚拟地址。

Have you tried jQuery Address? From Asual, the guys who made SWFAdress. Asual - jquery Address

The jQuery Address plugin provides powerful deep linking capabilities and allows the creation of unique virtual addresses that can point to a website section or an application state.

征棹 2024-08-30 18:17:05

History.js 文档齐全/维护良好,并且支持所有浏览器。

https://github.com/browserstate/history.js

从网站:

History.js 优雅地支持 HTML5 历史/状态 API
(pushState、replaceState、onPopState)在所有浏览器中。包括
继续支持数据、标题、replaceState。支持jQuery,
MooTools 和原型。对于 HTML5 浏览器,这意味着您可以
直接修改URL,不再需要使用哈希值。为了
HTML4 浏览器将恢复使用旧的 onhashchange
功能。

History.js is well documented/maintained and supports all browsers.

https://github.com/browserstate/history.js

From the site:

History.js gracefully supports the HTML5 History/State APIs
(pushState, replaceState, onPopState) in all browsers. Including
continued support for data, titles, replaceState. Supports jQuery,
MooTools and Prototype. For HTML5 browsers this means that you can
modify the URL directly, without needing to use hashes anymore. For
HTML4 browsers it will revert back to using the old onhashchange
functionality.

默嘫て 2024-08-30 18:17:05

我在 reallysimplehistory(nee dhtmlHistory)方面运气不错。它不是 jQuery 特有的,但它可以在 IE、firefox 和 webkit 中运行,并且不需要太多设置。

I've had good luck with reallysimplehistory (nee dhtmlHistory). It's not jQuery specific, but it works in IE, firefox, and webkit, and doesn't require much setup.

瘫痪情歌 2024-08-30 18:17:05

也许尝试这个 jQuery 历史记录插件: https://github.com/balupton/jquery-history/ 它提供跨浏览器支持、绑定到哈希值、重载哈希值等等。

它还有一个 Ajax 扩展,可以轻松地将您的网页升级为适当的 Ajax 应用程序: https ://github.com/balupton/jquery-ajaxy/

总体而言,它有良好的文档记录、支持且功能丰富。它还在这里赢得了赏金问题 如何在 URL 中显示 Ajax 请求或者

,如果您想使用 HTML5 History API,可以使用:https://github。 com/browserstate/history.js

Perhaps try this jQuery History plugin: https://github.com/balupton/jquery-history/ It provides cross browser support, binding to hashes, overloading hashes, all the rest.

There is also a Ajax extension for it, allowing it to easily upgrade your webpage into a proper Ajax application: https://github.com/balupton/jquery-ajaxy/

Overall it is well documented, supported and feature rich. It's also won a bounty question here How to show Ajax requests in URL?

Or if you want to use the HTML5 History API there is: https://github.com/browserstate/history.js

零時差 2024-08-30 18:17:05

AFAIK,所有历史记录插件都做同样的事情:

setInterval(function() {
   if(theHashChanged) {
      someFunction(oldHash,newHash);
   }
}, 500/*whatever*/);

这就是它的核心(减去浏览器黑客在不单击链接的情况下添加历史记录条目等)。它总是会出现错误,因为它有点像黑客,并且没有跨浏览器 API 来处理历史记录更改。

最重要的是,此类事情的用户体验不是很好。用户不明白何时必须点击后退按钮 4 次才能离开页面。

AFAIK, all history plugins do the same thing:

setInterval(function() {
   if(theHashChanged) {
      someFunction(oldHash,newHash);
   }
}, 500/*whatever*/);

That's pretty the core of it (minus browser hacks for adding history entries without clicking a link, etc.). It's always going to be buggy because it's a bit of a hack and there is no cross browser API for handling history changes.

On top of all that, the user experience for this sort of thing is not very good. Users don't understand when they have to click the back button 4 times to get off the page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文