One interesting feature I am trying to implement on my website is the ability for users to select a color theme for their browsing experience. I have successfully created different themed external CSS files and even developed a function to seamlessly switch between all the available color options.
However, there seems to be a slight hiccup in this process. Whenever a user clicks on a link to navigate to another page within the site, the selected theme reverts back to the default color that was initially set up for that specific page.
I am now curious if there is a way to dynamically modify the href attribute of each HTML page so that the corresponding CSS color file changes across every page visited. Alternatively, could implementing cookies be a feasible solution to remember the selected color theme? Although I have not delved into the realm of cookies yet, I am contemplating whether they could serve as a viable solution.
Shown below is the code snippet that effectively switches between different color themes within a single page:
HTML: Orange Theme Purple Theme Red Theme
Javascript: function setStyleSheet(url) { var stylesheet = document.getElementById("stylesheet"); stylesheet.setAttribute('href', url); }
All necessary CSS files are stored externally. Any assistance or guidance on this matter would be highly appreciated. Thank you.