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 differen开发者_JAVA技巧t 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 ?
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
:)
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.
精彩评论