Reputation: 37
var i = prompt("Enter The Password:");
if (i === "hawaiian tropical" || "Hawaiian Tropical") {
onclick="location.href='';"
}
there is the code. as you see, i am trying to make sure the password is 1 of the 2 and if they are, go to a specific link. But right now it is not working. Any suggestions?
Upvotes: 1
Views: 840
Reputation: 6180
I am a bit confused. The title and the body of the question each ask for two different things. If you want to go to a specific URL if the password is correct, then this would work:
var i = prompt("Enter The Password:");
if (i === "hawaiian tropical" || i === "Hawaiian Tropical") {
window.location.href = '';
}
While if you want to go to a specific URL when the password is correct and a button is clicked, use this:
var i = prompt("Enter The Password:");
if (i === "hawaiian tropical" || i === "Hawaiian Tropical") {
document.getElementById("myBtn").onclick = window.location.replace('');
}
<button id="myBtn">Click here</button>
Upvotes: 2