Archived topic
Horizontal Scrollable Tab with Localstorage to Remember Tab Last Opened
1 reply · Started by Cindy on January 12, 2018
Hi. I am using a horizontal scrollable tabs at https://www.littlechinesereaders.com/courses/level-1-lessons/ and vertical tabs at https://www.littlechinesereaders.com/guided-courses/ with the following javascript in the GP footer hook. I'd like to have a way of remembering the user's last visited tab (perhaps using localstorage) so that the same tab will load when the user revisits the page. How do I do that?
function openCity(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
document.getElementById("defaultOpen").click();
Hi there,
This will likely require a custom solution which is out of the scope of this support forum.
Have you checked with the source of the code and see if they might be able to help?
If not perhaps ask on here: https://stackoverflow.com/