₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,008 members, 8,448,215 topics. Date: Monday, 20 July 2026 at 12:53 AM

Toggle theme

I Need Active Tab To Stay Open On Refresh - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingI Need Active Tab To Stay Open On Refresh (347 Views)

1 Reply

I Need Active Tab To Stay Open On Refresh by Karleb(op): 9:26pm On Apr 11, 2021
Hey guys! I have these tabs. Mainly HTML, CSS and Vanilla JS which I got from W3schools. It displays different items on click but I want it to stay on a active tab even if the page is refresh.

https://codepen.io/karlebh/pen/LYxQyLW?editors=1000

I am really confused at this one. embarassed

I am thinking local or sessionStorage would be a better fit but I can't just wrap my head around the implementations.
Re: I Need Active Tab To Stay Open On Refresh by Jummate(m): 10:49pm On Apr 11, 2021
Karleb:
Hey guys! I have these tabs. Mainly HTML, CSS and Vanilla JS which I got from W3schools. It displays different items on click but I want it to stay on a active tab even if the page is refresh.

https://codepen.io/karlebh/pen/LYxQyLW?editors=1000

I am really confused at this one. embarassed

I am thinking local or sessionStorage would be a better fit but I can't just wrap my head around the implementations.
I think localStorage or sessionStorage will work. I'd go for localStorage given that it is permanent.

When a tab is clicked, save the reference of the clicked tab in localStorage in such a way that the reference to the recently clicked tab always overwrites the reference to the previously clicked tab. All these happen in the localStorage.

With this, tweak your code to always load the reference to the last active tab from the localStorage upon reload/refresh. This way, the active status will be triggered on the reference loaded from the localStorage.

I am not sure if this would help completely but I am sure you would be able to pick something from it.

Well done bro.
Re: I Need Active Tab To Stay Open On Refresh by Csami(m): 11:49pm On Apr 11, 2021
Don't know if it's possible though. Mine was to display data from my database onclick. Lemme checkout this local storage
1 Reply

How Long Should Refresh Tokens LastIs There Any Other Active Forums Like Nairaland In NigeriaJWT Token Refresh Automatize In Alteryx?234

What Is It Like To Be A Data Scientist At AmazonWhere Can I Lean Artificial Intelligence And Machine Language In AbujaHelp Out On Adsense Approval