I need to make a cookie which will remember the css stylesheet preference.
I switch stylesheets as:
function swapStylesheet(sheet){
document.getElementById('pagestyle').setAttribute('href', sheet);
}
And call it from buttons:
<a button class="Button" onclick="swapStylesheet('DayStyle.css')">Light</a>
<a button class="Button" onclick="swapStylesheet('NightStyle.css')">Dark</a>
So it changes the href to the css file of choice, but on refresh it changes back to default. Any way to create a cookie to remember the href preference? And can it be for all of the site?