JavaScript - redirect to other page if password is incorrect
What I want is use another script replace the "alert('That Is Correct!')" which can make it directly open the webpage rather then come up with alert first.
if (password === pass1)
alert('That Is Correct!');
else
window.location="S开发者_运维百科ITE-LINK";
</script>
Note: this script is for when open a page come up with asking password, I just want when the password is right it will continue opening the page, rather than alert message or open a certain page. Because this script is for a template, so it will open many different address.
Just invert the logic.
if (password != pass1)
window.location="SITE-LINK";
</script>
Do you mean, when the password is correct, open the address 'SITE-LINK'? If so, this will work.
if (password === pass1) {
window.location="SITE-LINK";
} else {
alert('Password is not correct');
}
Reverse the logical check
if(password!==pass1)
window.location="SITE-LINK";
精彩评论