Skip to content

Instantly share code, notes, and snippets.

@paulfarino
Created March 7, 2017 20:24
Show Gist options
  • Select an option

  • Save paulfarino/7d9467e3edac2fbaf77f7fc350a3765f to your computer and use it in GitHub Desktop.

Select an option

Save paulfarino/7d9467e3edac2fbaf77f7fc350a3765f to your computer and use it in GitHub Desktop.
<button onclick="increaseContrast()">Increase Contrast</button>
// Check local storage to see if the key 'contrast_increase' has been set to 'true'
window.onload = function() {
if (localStorage.getItem('contrast_increase') === 'true') {
increaseContrast()
} else {
console.log('Do Nothing')
}
};
// Set contrast hex code in local storage
function increaseContrast() {
document.getElementById('body').style.backgroundColor = "#DDDDDD";
localStorage.setItem('contrast_increase', 'true');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment