I have actually tried doing this for hours on end but didn't get any result. What I want to do specifically is when the user changes to another page, I want dark mode or light mode(whichever they have chosen) to stay the same.
HTML:
<div id="darkMode">
<input type="checkbox" class="tooltips" id="darkModeToggle" onchange=" changeMode();" autocomplete="on" checked>
</div>
JAVASCRIPT:
function changeMode() {
if (document.getElementById("darkModeToggle").checked === true)
{
document.getElementById("dark").href = "Style.css";
alert('You have turned on Dark Mode. Press Enter to continue.');
localStorage.setItem("DarkMode", "on");
}
else{
document.getElementById("dark").href = "lightmode2.css";
alert('You have turned on Light Mode. Press Enter to continue.');
localStorage.setItem("DarkMode", "off");
}
}
I would like to have code of this in Javascript or CSS if possible, otherwise other languages are fine.
Aucun commentaire:
Enregistrer un commentaire