简体   繁体   English

如何实现类似于Facebook的面包屑导航?

[英]How do I implement bread-crumb navigation similar to Facebook?

I'm trying to make an Ajax Web Application that uses bread-crumbing to allow the use of the Back and Forward Buttons, but still have that slick ajax page movement. 我正在尝试制作一个Ajax Web应用程序,该应用程序使用面包屑来允许使用“后退”和“前进”按钮,但仍然具有流畅的Ajax页面移动性。

An excellent example is Facebook's image gallery. 一个很好的例子是Facebook的图片库。

When you click 'Next' the URL changes to the respective URL but the entire page does not update. 当您单击“下一步”时,URL会更改为相应的URL,但整个页面不会更新。 It's a really smooth interface and I'd like to mimic that. 这是一个非常流畅的界面,我想模仿一下。

Anyone got a tutorial/write up on how this works? 任何人都有关于它如何工作的教程/文章吗?

Thanks. 谢谢。

Facebook uses the URL-Anchor-Identifier to store the code needed for their AJAX code. Facebook使用URL锚标识符存储其AJAX代码所需的代码。 This allows changing the URL without having the website reloaded. 这允许更改URL而无需重新加载网站。

Example: http://somedomain.com/#ajax_data_here 示例: http://somedomain.com/#ajax_data_herehttp://somedomain.com/#ajax_data_here

Now it's to you to write a smart format for your ajax data and to parse that data. 现在,您要为ajax数据编写一种智能格式并解析该数据。


Update Dec 2012: 2012年12月更新:

I've recently encountered the following method for changing the path within the URL without reloading. 我最近遇到了以下方法,无需重新加载即可更改URL中的路径。 Although it only works with newer browsers, I thought I'd append it: 尽管它仅适用于较新的浏览器,但我想我应该附加一下:

As far as I am aware there are two main ways that this effect is achieved: 据我所知,有两种主要方法可以达到这种效果:

  1. Using the anchor portion of the url (#gallery) 使用网址的锚点(#gallery)
  2. Using a hidden iframe 使用隐藏的iframe

There are pre-built solutions that you can use to leverage this kind of functionality without having to deal with writing the code. 您可以使用预先构建的解决方案来利用这种功能,而不必处理代码。 For example if you are working with asp.net then you can use the Ajax History Control: 例如,如果您正在使用asp.net,则可以使用Ajax历史记录控件:

If you are using JQuery, look at the Address plugin. 如果使用的是JQuery,请查看Address插件。

http://www.asual.com/jquery/address/ http://www.asual.com/jquery/address/

If you're using jQuery, there are lots of suggestions documented here: https://stackoverflow.com/questions/116446/what-is-the-best-back-button-jquery-plugin 如果您使用的是jQuery,则此处记录了很多建议: https : //stackoverflow.com/questions/116446/what-is-the-best-back-button-jquery-plugin

I've personally used jQuery Address , and it's super easy and very effective. 我个人使用过jQuery Address ,它非常简单而且非常有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM