I am making a page where the user can change several looks/style on the page through drop-down menu, which changes css file name. I have managed to change the stylesheet through drop-down menu but I would now like to save the currently css file on local storage. For example if the user changes to stylesheet3.css (through drop-down menu) then this style/look will be set next time user visits page. Here is my code:
HTML:
<link id="myStyleSheet" href="stylesheet1.css" rel="stylesheet" type="text/css"> I put an id in stylesheet
<div id="changeLook">
Change style:
<select id="changeStyle" onchange="changeStyleFunction()">
<option value="stylesheet1.css">Style 1</option>
<option value="stylesheet2.css">Style 2</option>
<option value="stylesheet3.css">Style 3</option>
<option value="stylesheet4.css">Style 4</option>
</select>
</div>
JavaScript:
function changeStyleFunction() {
var href;
var value = document.getElementById("changeStyle").value;
localStorage.setItem("GetData" , value); //Here is my biggest problem???
href = value;
document.getElementById('myStyleSheet').href = href;
}
How do I make the current stylesheet(value) get in to localStore? I am very new at Local Storages... Thanks!