I'm looking to create a cookie that will store the preference for a specific CSS stylesheet. I currently have a function in place that allows me to switch between stylesheets:
function swapStylesheet(sheet){
document.getElementById('pagestyle').setAttribute('href', sheet);
}
This function is called from buttons like so:
<a button class="Button" onclick="swapStylesheet('DayStyle.css')">Light</a>
<a button class="Button" onclick="swapStylesheet('NightStyle.css')">Dark</a>
However, I've noticed that the href reverts back to the default stylesheet upon refreshing the page. Is there a way to implement a cookie that remembers the preferred stylesheet? And can this cookie be applied site-wide?