历史记录插件(jQuery 或 AJAX 历史记录的一般使用)

发布于 2024-11-08 03:17:38 字数 1503 浏览 2 评论 0原文

更新问题:2011 年 5 月 19 日 注意:对于像我这样的新手 - 首先看看这个,看看它是否有帮助,我发现它非常有用!

  1. jQuery 历史记录插件
  2. http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/

原始问题

我在网页设计方面相对缺乏经验,但一直致力于在我的新网站上实施历史解决方案。

注意:我现在已经查看了上面链接中的解决方案 - jQuery.History @ http://tkyk.github.com /jquery-history-plugin/ 似乎对我有用,但有很多选择!

我已经阅读了一些内容,在下面得到了一些很好的输入(谢谢!),现在有点理解 T9b 下面提到的推理了;你不能回答我原来的问题——现在这有点道理了。

一般来说:有页面历史记录和元素历史记录,正如我现在所理解的那样。

原始问题#1: 示例:我想将 PageA.html、#divA1 而不是整个 PageA.html 加载到主页上的 #content div 中,并使用历史记录解决方案。

  • 不能这样做,因为您正在混合页面历史记录 (PageA.html) 和元素历史记录 (#divA1)。

答案#1: 如果我想使用“历史”解决方案(后退、前进、书签等...),我实际上必须创建一个单独的(新)divA1.html 文件 - 该方式的基本要求历史类型的解决方案工作。


问题#2

我开始查看下面答案中的一些项目 - 会话对我来说可能太复杂了,抱歉。那么,

  • 是否有一个链接指向在 javascript 中专门为历史类型应用程序设置索引数组的示例,如下所示?
  • 理解(如果浏览器刷新或添加书签,这不会存储信息,我认为这是正确的?)
  • 但是,这是否允许用户在浏览页面时后退、前进,该页面有多个从隐藏 div 加载的内容在页面内?: (除非他们刷新页面等...,我认为这就是 T9b 下面所说的?)

再次感谢您的耐心 - 我确信这些不是最聪明的问题,但我会继续阅读等...并努力变得更好,感谢迄今为止的所有帮助!

UPDATED Question: 5/19/11
NOTE: for complete newbies like myself - take a look at this first to see if it helps, i found it very useful!

  1. jQuery History Plugin
  2. http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/

Original Question:

I am relatively inexperienced in web design, but have been working on implementing a History solution on my new website.

Note: I have now looked at the solutions in the link above
- jQuery.History @ http://tkyk.github.com/jquery-history-plugin/ seemed to work for me but there are a lot of options!

I've done some reading, gotten some good input below (thank you!), and now kind of understand the reasoning T9b refers to below; you can't do my original question - that makes some sense now.

In General: there is Page History, and Element History as i now understand it.

Original Question #1:
example: I wanted to load PageA.html, #divA1 instead of the whole PageA.html into my #content div on my main page and use a history solution.

  • can't do that, because you are mixing Page History (PageA.html) and Element History (#divA1).

Answer #1:
If i want to use a "history" solution (back, forward, bookmarks, etc...) i would actually have to create a separate (new) divA1.html file - basic requirement of the way history type solution work.


Question #2:

I started looking at some of the items in the answer below - Sessions will probably be too complicated for me, sorry. So

  • is there a link to an example of setting up an index array in javascript specifically for a history type application like suggested below?
  • Understanding (this will not store information if the browser is refreshed, or bookmarked, which i think is correct?)
  • But will that allow back, forward for the user while they are navigating a page say that has multiple content that is loading from hidden div's within the page?:
    (unless they refresh the page, etc..., which I think is what T9b is saying below?)

Again, thank you for your patience - I'm sure these are not the smartest questions but I'll keep reading etc... and trying to get better, appreciate all the help so far!

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

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

发布评论

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

评论(2

挽心 2024-11-15 03:17:38

如果我理解正确的话 - 您正在将网站上的另一个页面加载到可滚动的 div 中(例如在使用 iframe 的地方?)并且您想知道这些加载的历史记录,以便您可以自由地前后导航,例如你会在浏览器中做什么?但是您在使用 .history() 插件时遇到了问题,因为它只处理整个页面,而不处理 div 的内容。

对了。如果我正确理解了这一点,那么我认为最好的选择是最初将历史记录存储在带有索引和变量的数组中,然后使用索引来确定您当前的位置与上次的位置相对应。但这取决于您想要提供历史记录多长时间。一旦您刷新页面或离开网站,它就会丢失。

如果您希望它持续更长时间,那么您还必须考虑在服务器上存储历史记录,也许使用会话。

目前还不完全清楚你想要做什么,我可能完全误解了!

If I understand you correctly - you are loading another page on your site into a scrollable div (for example in the place of using an iframe?) and you want to know the history of those loads so that you could navigate freely backwards and forwards like you would do in the browser? But you are having problems with the .history() plugin because it only deals with the page as a whole and not the contents of the div.

Righto. If I have understood this correctly then I think your best bet would be initially to just store the history in an array with an index and a variable and then use the index to determine where you currently are against where you last were. But that depends on how long you want to make the history available. It will be lost as soon as you refresh the page or leave the site.

If you want it to persist longer then you will also have to look into stocking the history on the server, perhaps using sessions.

It's not entirely clear what you are trying to do, and I may have completely misunderstood!

风筝在阴天搁浅。 2024-11-15 03:17:38

有关一般介绍,请参阅 Html5 历史记录 API 指南:http://diveintohtml5.info/history.html

Html5允许您修改“真实”历史记录,即您不需要依赖哈希标签。它并不与所有浏览器的所有版本兼容,这就是为什么您可能需要 HistoryJS (这是 jQuery 历史记录插件的后继者)

如果您之后仍有疑问,我建议您立即询问他们,但要更具体地说明您想要实现的目标(例如发布您遇到的确切问题或您所在的位置)卡住了)。

For general introduction see this guide to Html5 History API: http://diveintohtml5.info/history.html

Html5 allows you to modify "real" history, i.e. you don't need to rely on hash-tags. It is not compatible with all versions of all the browsers, which is why you might need HistoryJS (which is a successor to jQuery history plugin)

If you still have questions after that, I recommend you ask them right away, but be more specific as to what you want to achieve (e.g. post the exact problem you are having or the place you are stuck on).

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