开发者

JavaScript - redirect to other page if password is incorrect

开发者 https://www.devze.com 2023-03-12 10:49 出处:网络
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.

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";
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号