Page 1 of 1
Display last active tab after page refresh
Posted: 26 Nov 2014, 17:27
by Marius
I have a tabs effect on a web page and when the page is refreshed it loses the last active tab and goes back to the first tab.
How to make so after the page refresh to remain active the last opened tab?
Has anyone come across this problem and know how to solve it?
Display last active tab after page refresh
Posted: 26 Nov 2014, 17:40
by Admin
Hi,
You can use the
sessionStorage JavaScript object to store data in the browser session, that can be used after page refresh.
You can add data in browser session using this code:
Code: Select all
sessionStorage.setItem('name', value);
And you can get /use the value associated to "name" with this:
Code: Select all
if(sessionStorage.getItem('name')) {
var some_var = sessionStorage.getItem('name');
}
- In this page:
Creating Tabs Effect with JavaScript is an example with tabs effect that uses this technique to keep active the last opened tab, after page refresh.