My JavaScript code works in Firefox & MSIE. But not in Chrome. In FF or MSIE, the "saved" button works, changes background image when I reload. But in Chrome, the "saved" button does nothing. And there's no error message in Chrome Inspector. "Reload" button works in Chrome though.
var skin = "";
var myRegExp = /;/g;
if (skin == "blue") {
document.body.background = "blue.jpeg"
} else if (skin == "green") {
document.body.background = "green.jpeg"
}
function setCookie() {
skin = document.f.s.value;
if (skin == 'blue' || skin == 'green') {
document.cookie = "skin=" + skin + ';expires=' + expireDate.toGMTString();
} else {
alert('Not Valid Skin Color');
}
}
<form name="f">
Change Skin to:
<input type="text" name="s" /> <br> Colors include: blue, green<br>
<input type="button" name="saved" value="Save" onclick="setCookie()">
<input type="button" name="reload" value="Reload" onclick="location.reload()">
</form>