jquery推送自定义历史记录
在我的项目中,我制作了自定义选项卡系统,这非常简单:一堆 ; ..
用作选项卡,以及一堆
作为每个选项卡的内容,因此无论单击什么 元素,我都会获取其索引,并将显示带有相同的索引...
现在,每个选项卡都可以显示不同类型的内容,因此例如在选项卡中我可以打开打开的主页,然后单击新闻转到新闻页面(仍然相同的选项卡),然后转到新闻列表单击新闻标题以阅读其余新闻...在第二个选项卡上,我可以执行另一个涉及导航到其他页面等的场景...
所以我的问题是,有没有办法跟踪每个选项卡的单独的历史记录?就像在单独的数组中的每个选项卡中访问的故事页面一样,一旦单击该选项卡,就根据该数组重写浏览器的历史记录,或者类似的东西?
In my project I've made my custom tabbing system, which is pretty simple: a bunch of <a> ..</a>
which serve as tabs, and a bunch of <div> ...</div>
which serve as content for each tab, so whatever <a >
element is clicked, I get its index, and will show the div with the same index ...
now, each of these tabs can show different type of content , so for example in a tab I can open open home page, then click on news to go to news page (still same tab) and then on news list click on of the news headings to read the rest of the news ... and on second tab i can do another scenario involving navigation to other pages , etc ...
so my question is, is there any way to keep track of each tab's history separately ?so like story pages visited in each tab in separate arrays, and once that tab is clicked, rewrite browser's history based on that array, or something like that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在查看 hashchange 之前,您应该先查看 History API...
History API 简介
使用 History API 让 AJAX 用户友好、Google 友好、友好友好
可以使用 hashchange 作为后备,但您应该考虑使用历史 API。
希望这有帮助
:)
You should look at the History API, before you look at hashchange...
Introduction to the History API
Making AJAX user friendly, google friendly, friendly friendly using the History API
You can use hashchange as a fallback, but you should look at using the history API.
Hope this helps
:)
查看 jQuery hashchange 插件: http://benalman.com/projects/jquery-hashchange-plugin /
它包装了
window.onhashchange
事件以支持旧版浏览器。基本上,单击每个选项卡应该将您的用户导航到不同的哈希/锚点(因此链接将类似于 #home、#about),并且您的选项卡切换代码将在 URL 更改时运行。Check out the jQuery hashchange plugin: http://benalman.com/projects/jquery-hashchange-plugin/
It wraps the
window.onhashchange
event for support with older browsers. Basically, clicking each tab should navigate your user to a different hash/anchor (so links will be like #home, #about) and your tab switching code will run when the URL changes.