[英]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.我想要的是使用另一个脚本替换“alert('That Is Correct.')”,它可以直接打开网页,而不是先提出警报。
if (password === pass1)
alert('That Is Correct!');
else
window.location="SITE-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'?你的意思是,当密码正确时,打开地址“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";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.