Skip to content Skip to sidebar Skip to footer

Keep Track Of Which Tab Was Being Viewed When Page Is Refreshed

I have a webpage which has three tabs, and depending on which tab is clicked, the appropriate content is visible. This showing/hiding of the content on clicking of tabs is handled

Solution 1:

You have a few options:

  • use a fragment identifier (add something like #tab3 to the URL)
  • store in a cookie
  • use local storage

Depending on what browsers you want to support and how long you want to persist the option you can pick any of them.


Solution 2:

Addtab id to the URL as an anchor when tab is clicked, e.g. http://www.mysite.com/page.html#tabId

Then when page loads you check for presence of tab id in url and activate required tab


Solution 3:

You can use cookie, or link hash. For example: http://jqueryfordesigners.com/api-filter-find/


Post a Comment for "Keep Track Of Which Tab Was Being Viewed When Page Is Refreshed"