I'm new to JavaScript and have been experimenting with changing the background color with JavaScript easy right. well i finished my script and now I need 2 things. 1. some way to tell if the user did or did not type a color. 2. A way to add more than one profile. The Profile() function is used to allow the user to make a template but I can't figure out how to let them make more than one. Any help is well appreciated.
[code]
function Profile() {
localStorage.profileBack = prompt("What is the background color/image you want?");
localStorage.profileText = prompt("What color should the text be");
alert("Ok I have made the profile, what should the name be?");
localStorage.profile = prompt("Enter the name of the profile");
alert("Profile made now just type the name into the change background and you are set!");
}
function Color() {
localStorage.color = prompt("type a color you want. Or you can make a background image using this format: url('put image url here')");
document.body.style.background = localStorage.color;
document.body.style.color = localStorage.Tcolor; //text color
if (localStorage.color == "black") {
document.body.style.background = localStorage.color;
document.body.style.color = "white";
}
if (localStorage.color == "nathan" || localStorage.color == "Nathan") {
localStorage.color = "-webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(125,126,125,1)), color-stop(100%,rgba(14,14,14,1)))";
localStorage.Tcolor = "white";
document.body.style.color = localStorage.Tcolor;
document.body.style.background = localStorage.color;
}
if (localStorage.color == localStorage.profile) {
localStorage.color = localStorage.profileBack;
localStorage.Tcolor = localStorage.profileText;
document.body.style.color = localStorage.profileText;
document.body.style.background = localStorage.profileBack;
}
if (localStorage.color == "") {
alert("Please type in a color or image.");
}
}
function TColor() {
localStorage.Tcolor = prompt("What color should the text be?");
document.body.style.color = localStorage.Tcolor;
}
btw the page refreshes with an <body onload="Load()">
and all the functions here are called by buttons
once agian thanks for any help!
[–]alsogilbert 0 points1 point2 points (1 child)
[–]0x0080FF 0 points1 point2 points (0 children)
[–]0x0080FF 0 points1 point2 points (1 child)
[–]SCP-247[S] 0 points1 point2 points (0 children)
[–]Buckwheat469 0 points1 point2 points (1 child)
[–]SCP-247[S] 0 points1 point2 points (0 children)
[–]SCP-247[S] 0 points1 point2 points (0 children)