I Am Trying To Make A Password System, In Which for Specific Password, It Redirects to a Custom Webpage,
Like a A Support-type System
But,
Whenever I Type The Password: tanishq1e01
, Or tanishq1e02
, It Always Returns The Webpage For
tanishq1e02
Webpage..?
Why??
I Expected That It Would Output A Different Webpage for Each Password,
But It Doesn't Work!
var ff;
let tanishq1e01 = "tanishq1e01";
let tanishq1e02 = "tanishq1e02"
ff = prompt("Enter Given Password By Prattay: ");
if (ff == tanishq1e01) {
window.location.href = "suppstsasd/tanishq1e01suppasd.html";
} else if (ff = tanishq1e02) {
window.location.href = "suppstsasd/tanishq1e02suppasd.html";
} else {
confirm("Not Right Password! Refreshing...");
window.location.reload();
}
CodePudding user response:
You have a =
assignment instead of ==
or ===
compare in the second test.
Here is a more elegant way, where it is easier to add locations
This is assuming you want to use such insecure way to load pages.
const locations = {
"tanishq1e01": "suppstsasd/tanishq1e01suppasd.html",
"tanishq1e02": "suppstsasd/tanishq1e02suppasd.html"
}
let ff = prompt("Enter Given Password By Prattay: ");
let loc = locations[ff];
if (!loc) {
alert("Not Right Password! Refreshing...");
window.location.reload();
}
else {
console.log("Going to", loc);
window.location.href = loc;
}